:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #059669;
    --warning-color: #d97706;
    --error-color: #dc2626;
    --bg-color: #f8fafc;
    --border-color: #e2e8f0;
    --text-color: #1e293b;
    --text-muted: #64748b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
}

/* Header */
.header {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header__title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.header__user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Login Forms */
.login {
    max-width: 400px;
    margin: 4rem auto;
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.login__title {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group__label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group__input, .form-group__textarea, .form-group__select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

.form-group__textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group__input:focus, .form-group__textarea:focus, .form-group__select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group__file {
    border: 2px dashed var(--border-color);
    padding: 2rem;
    text-align: center;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.form-group__file:hover {
    border-color: var(--primary-color);
    background-color: #f8fafc;
}

.form-group__file input[type="file"] {
    display: none;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.btn--primary {
    background-color: var(--primary-color);
    color: white;
}

.btn--primary:hover {
    background-color: #1d4ed8;
}

.btn--secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn--success {
    background-color: var(--success-color);
    color: white;
}

.btn--warning {
    background-color: var(--warning-color);
    color: white;
}

.btn--small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn--full {
    width: 100%;
}

.btn--icon {
    padding: 0.5rem;
    width: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Main Content */
.main {
    padding: 2rem;
}

.main__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.main__title {
    font-size: 2rem;
    font-weight: 600;
}

.main__actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Search and Filters */
.search-controls {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.search-controls__row {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-controls__input {
    flex: 1;
    min-width: 300px;
}

.filter-tabs {
    display: flex;
    gap: 0.5rem;
}

.filter-tab {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-tab--active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Plan Grid */
.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.plan-card {
    background: white;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all 0.2s;
    cursor: pointer;
}

.plan-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-1px);
}

.plan-card__header {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    gap: 1rem;
}

.plan-card__logo {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    background-color: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    border: 2px solid var(--border-color);
    object-fit: cover;
}

.plan-card__info {
    flex: 1;
}

.plan-card__client {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.plan-card__election {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.plan-card__meta {
    padding: 0 1.5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.plan-card__url {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-muted);
    background-color: var(--bg-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.plan-card__status {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.plan-card__status--draft {
    background-color: #fef3c7;
    color: #92400e;
}

.plan-card__status--published {
    background-color: #d1fae5;
    color: #065f46;
}

.plan-card__status--archived {
    background-color: #f3f4f6;
    color: #374151;
}

.plan-card__actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Media Plan Grid */
.media-plan {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.media-plan__header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.media-plan__title {
    font-size: 1.5rem;
    font-weight: 600;
}

.media-plan__grid {
    overflow-x: auto;
}

.media-plan__table {
    width: 100%;
    min-width: 800px;
    border-collapse: collapse;
}

.media-plan__week-header {
    background-color: var(--bg-color);
    font-weight: 600;
    text-align: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    min-width: 120px;
}

.media-plan__audience-header {
    background-color: #f1f5f9;
    font-weight: 600;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.media-plan__placement-row {
    border-bottom: 1px solid var(--border-color);
}

.media-plan__placement-name {
    padding: 1rem;
    font-weight: 500;
    background-color: #fafafa;
    border-right: 1px solid var(--border-color);
    min-width: 200px;
}

.media-plan__cell {
    padding: 0.5rem;
    border-right: 1px solid var(--border-color);
    min-height: 60px;
    max-width: 150px;
    word-wrap: break-word;
    vertical-align: top;
    position: relative;
    cursor: pointer;
}

.media-plan__cell:hover {
    background-color: #f8fafc;
}

.media-plan__cell--editable {
    background-color: #fefefe;
}

/* Enhanced Creative Visual System */
.media-plan__creative {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.625rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    margin: 0.125rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.media-plan__creative:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    border-color: rgba(255,255,255,0.3);
}

.media-plan__creative--span {
    position: relative;
}

/* hiding after pseudo element for now
.media-plan__creative--span::after {
    content: '↔';
    margin-left: 0.25rem;
    font-size: 0.6rem;
    opacity: 0.8;
}
*/

.media-plan__creative-icon {
    font-size: 0.875rem;
    line-height: 1;
}

.media-plan__creative-text {
    white-space: nowrap;
    text-wrap: wrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

.media-plan__creative-delete {
    margin-left: 0.25rem;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.2s;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0 0.25rem;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
}

.media-plan__creative:hover .media-plan__creative-delete {
    opacity: 1;
}

.media-plan__creative-delete:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Creative type legend */
.creative-legend {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: white;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    flex-wrap: wrap;
}

.creative-legend__item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
}

.creative-legend__icon {
    font-size: 1rem;
}

/* Enhanced creative selection */
.creative-option {
    padding: 0.75rem;
    cursor: pointer;
    border-radius: 6px;
    margin-bottom: 0.25rem;
    transition: all 0.2s;
    border: 1px solid transparent;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.creative-option:hover {
    background-color: var(--bg-color);
    border-color: var(--border-color);
}

.creative-option--selected {
    border-color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.1);
}

.creative-option__icon {
    font-size: 1.25rem;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.creative-option__content {
    flex: 1;
    min-width: 0;
}

.creative-option__name {
    font-weight: 500;
    margin-bottom: 0.125rem;
}

.creative-option__meta {
    font-size: 0.75rem;
    opacity: 0.8;
    display: flex;
    gap: 0.5rem;
}

.creative-option__type {
    background: rgba(0,0,0,0.1);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
}

/* Client View Specific */
.client-header {
    background: linear-gradient(135deg, var(--primary-color), #1d4ed8);
    color: white;
    padding: 2rem;
    text-align: center;
}

.client-header__logo {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    margin: 0 auto 1rem;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
}

.client-header__title {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.client-header__subtitle {
    font-size: 1.25rem;
    opacity: 0.9;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal__content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal__title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal__close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal__buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/* Creative Selection */
.creative-select {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
}

.creative-option {
    padding: 0.75rem;
    cursor: pointer;
    border-radius: 4px;
    margin-bottom: 0.25rem;
    transition: all 0.2s;
}

.creative-option:hover {
    background-color: var(--bg-color);
}

.creative-option--selected {
    background-color: var(--primary-color);
    color: white;
}

.creative-option__name {
    font-weight: 500;
}

.creative-option__version {
    font-size: 0.875rem;
    opacity: 0.8;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.error {
    color: var(--error-color);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.success {
    color: var(--success-color);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

.error-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-color);
}

.error-content {
    text-align: center;
    max-width: 500px;
    padding: 2rem;
}

.error-content h1 {
    font-size: 2rem;
    color: var(--error-color);
    margin-bottom: 1rem;
}

.week-range {
    display: flex;
    gap: 1rem;
    align-items: end;
}

.week-range__input {
    flex: 1;
}

.week-range__input label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.assignment-menu {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    min-width: 150px;
    z-index: 1001;
}

.assignment-menu__item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
}

.assignment-menu__item:last-child {
    border-bottom: none;
}

.assignment-menu__item:hover {
    background-color: var(--bg-color);
}

 /* Enhanced Mobile Responsive Design */
        @media (max-width: 768px) {
            /* Header optimizations */
            .header {
                padding: 0.75rem 1rem;
                flex-wrap: wrap;
                gap: 0.5rem;
            }
            
            .header__title {
                font-size: 1.25rem;
            }
            
            .header__user {
                font-size: 0.875rem;
            }
            
            /* Main content optimizations */
            .main {
                padding: 1rem;
            }
            
            .main__header {
                flex-direction: column;
                align-items: stretch;
                gap: 1rem;
            }
            
            .main__title {
                font-size: 1.5rem;
            }
            
            .main__actions {
                justify-content: center;
                flex-wrap: wrap;
            }
            
            /* Login form optimizations */
            .login {
                margin: 2rem auto;
                padding: 1.5rem;
                max-width: 350px;
            }
            
            /* Plan grid optimizations */
            .plan-grid {
                grid-template-columns: 1fr;
                gap: 1rem;
            }
            
            .plan-card__header {
                padding: 1rem;
            }
            
            .plan-card__logo {
                width: 48px;
                height: 48px;
                font-size: 1.25rem;
            }
            
            .plan-card__client {
                font-size: 1.125rem;
            }
            
            .plan-card__meta {
                padding: 0 1rem 1rem;
                flex-direction: column;
                align-items: flex-start;
                gap: 0.5rem;
            }
            
            .plan-card__actions {
                padding: 0.75rem 1rem;
                justify-content: center;
            }
            
            /* Search controls optimizations */
            .search-controls {
                padding: 1rem;
            }
            
            .search-controls__row {
                flex-direction: column;
                align-items: stretch;
                gap: 1rem;
            }
            
            .search-controls__input {
                min-width: 100%;
            }
            
            .filter-tabs {
                justify-content: center;
                flex-wrap: wrap;
            }
            
            .filter-tab {
                flex: 1;
                min-width: 60px;
                text-align: center;
                font-size: 0.875rem;
            }
            
            /* Modal optimizations - Critical improvements */
            .modal {
                padding: 0.5rem;
                align-items: flex-start;
                padding-top: 2rem;
            }
            
            .modal__content {
                max-width: 100%;
                width: 100%;
                max-height: calc(100vh - 4rem);
                padding: 1.5rem;
                margin: 0;
                border-radius: 8px 8px 0 0;
            }
            
            .modal__header {
                margin-bottom: 1rem;
                position: sticky;
                top: 0;
                background: white;
                z-index: 10;
                padding-bottom: 0.5rem;
                border-bottom: 1px solid var(--border-color);
            }
            
            .modal__title {
                font-size: 1.125rem;
                line-height: 1.3;
            }
            
            .modal__close {
                font-size: 1.75rem;
                padding: 0.25rem;
                min-width: 36px;
                min-height: 36px;
                display: flex;
                align-items: center;
                justify-content: center;
            }
            
            .modal__buttons {
                flex-direction: column-reverse;
                gap: 0.75rem;
                position: sticky;
                bottom: 0;
                background: white;
                padding-top: 1rem;
                margin-top: 1rem;
                border-top: 1px solid var(--border-color);
            }
            
            .modal__buttons .btn {
                width: 100%;
                padding: 0.875rem;
                font-size: 1rem;
            }
            
            /* Form optimizations for mobile */
            .form-group {
                margin-bottom: 1.25rem;
            }
            
            .form-group__input, 
            .form-group__textarea, 
            .form-group__select {
                padding: 0.875rem;
                font-size: 1rem;
                -webkit-appearance: none;
                appearance: none;
            }
            
            /* Prevent zoom on input focus on iOS */
            .form-group__input:focus,
            .form-group__textarea:focus,
            .form-group__select:focus {
                font-size: 1rem;
            }
            
            .form-group__file {
                padding: 1.5rem 1rem;
                min-height: 80px;
            }
            
            /* Creative selection optimizations */
            .creative-select {
                max-height: 150px;
                border-radius: 6px;
            }
            
            .creative-option {
                padding: 1rem 0.75rem;
                margin-bottom: 0.5rem;
            }
            
            .creative-option__icon {
                width: 36px;
                height: 36px;
                font-size: 1.125rem;
            }
            
            .creative-option__name {
                font-size: 0.9rem;
            }
            
            .creative-option__meta {
                font-size: 0.75rem;
            }
            
            /* Media plan table optimizations */
            .media-plan__table {
                font-size: 0.875rem;
                min-width: 600px;
            }
            
            .media-plan__week-header,
            .media-plan__placement-name {
                padding: 0.75rem 0.5rem;
                min-width: 80px;
            }
            
            .media-plan__cell {
                padding: 0.375rem;
                min-height: 50px;
            }
            
            .media-plan__creative {
                font-size: 0.6875rem;
                padding: 0.25rem 0.5rem;
                margin: 0.125rem 0;
            }
            
            .media-plan__creative-text {
                max-width: 80px;
            }
            
            /* Client header optimizations */
            .client-header {
                padding: 1.5rem 1rem;
            }
            
            .client-header__logo {
                width: 60px;
                height: 60px;
                font-size: 1.5rem;
            }
            
            .client-header__title {
                font-size: 1.5rem;
            }
            
            .client-header__subtitle {
                font-size: 1rem;
            }
            
            /* Creative legend optimizations */
            .creative-legend {
                padding: 0.75rem;
                gap: 0.5rem;
            }
            
            .creative-legend__item {
                padding: 0.375rem 0.5rem;
                font-size: 0.75rem;
            }
            
            /* Button optimizations */
            .btn {
                padding: 0.75rem 1rem;
                font-size: 0.9rem;
                min-height: 44px; /* Touch target size */
            }
            
            .btn--small {
                padding: 0.5rem 0.75rem;
                font-size: 0.8rem;
                min-height: 36px;
            }
            
            .btn--icon {
                min-width: 36px;
                min-height: 36px;
                padding: 0.375rem;
            }
        }

        /* Extra small screens */
        @media (max-width: 480px) {
            .header {
                padding: 0.5rem;
            }
            
            .header__title {
                font-size: 1.125rem;
            }
            
            .main {
                padding: 0.75rem;
            }
            
            .main__title {
                font-size: 1.375rem;
            }
            
            .login {
                margin: 1rem auto;
                padding: 1rem;
                max-width: 320px;
            }
            
            .modal {
                padding: 0.25rem;
                padding-top: 1rem;
            }
            
            .modal__content {
                max-height: calc(100vh - 2rem);
                padding: 1rem;
                border-radius: 6px 6px 0 0;
            }
            
            .search-controls {
                padding: 0.75rem;
            }
            
            .plan-card__header {
                padding: 0.75rem;
            }
            
            .media-plan__table {
                min-width: 500px;
            }
            
            .media-plan__week-header,
            .media-plan__placement-name {
                padding: 0.5rem 0.375rem;
                font-size: 0.8rem;
                min-width: 70px;
            }
        }

        /* Landscape phone optimization */
        @media (max-width: 768px) and (orientation: landscape) {
            .modal {
                align-items: center;
                padding: 0.5rem;
            }
            
            .modal__content {
                max-height: calc(100vh - 1rem);
            }
            
            .client-header {
                padding: 1rem;
            }
            
            .client-header__title {
                font-size: 1.25rem;
            }
            
            .client-header__subtitle {
                font-size: 0.9rem;
            }
        }

        /* High DPI screen optimizations */
        @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
            .media-plan__creative {
                border-width: 0.5px;
            }
            
            .plan-card {
                border-width: 0.5px;
            }
        }

        /* Dark mode support for mobile */
        @media (prefers-color-scheme: dark) and (max-width: 768px) {
            .modal__content {
                background: #1e293b;
                color: white;
            }
            
            .modal__header {
                border-bottom-color: #374151;
                background: #1e293b;
            }
            
            .modal__buttons {
                border-top-color: #374151;
                background: #1e293b;
            }
        }

        /* Focus and accessibility improvements for mobile */
        @media (max-width: 768px) {
            .btn:focus,
            .form-group__input:focus,
            .form-group__textarea:focus,
            .form-group__select:focus {
                outline: 2px solid var(--primary-color);
                outline-offset: 2px;
            }
            
            .creative-option:focus {
                outline: 2px solid var(--primary-color);
                outline-offset: 1px;
            }
            
            /* Increase touch targets */
            .plan-card__actions .btn {
                min-width: 44px;
                min-height: 44px;
            }
            
            .filter-tab {
                min-height: 44px;
                display: flex;
                align-items: center;
                justify-content: center;
            }
        }