/* Fed Circuit Tools Admin Portal - Responsive CSS */

/* === Reset & Base Styles === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Container === */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 14px 20px;
}

/* Override for document view page wrapper */
.page-wrapper {
    max-width: none;
    margin: 0;
    padding: 0;
}

/* === Header === */
.header {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 0;
    margin: -14px -20px 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.header-left {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px;
}

.header-brand {
    font-size: 20px;
    font-weight: 700;
}

.header-sep {
    font-size: 16px;
    opacity: 0.7;
    margin: 0 2px;
}

.header-page {
    font-size: 18px;
    font-weight: 400;
    opacity: 0.95;
}

.header-actions {
    flex-shrink: 0;
}

/* === Filters Section === */
.filters-section {
    background: white;
    padding: 10px 16px;
    border-radius: 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.filters-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 120px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 3px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.filter-select {
    padding: 6px 10px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.filter-select:focus {
    outline: none;
    border-color: #3b82f6;
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.btn {
    padding: 7px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background-color: #2563eb;
}

.btn-secondary {
    background-color: #e5e7eb;
    color: #333;
}

.btn-secondary:hover {
    background-color: #d1d5db;
}

.btn-back {
    display: inline-block;
    padding: 8px 16px;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.btn-back:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* === Results Summary === */
.results-summary {
    background: white;
    padding: 7px 16px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.results-summary p {
    font-size: 14px;
    color: #666;
}

.results-summary strong {
    color: #1e3a8a;
    font-weight: 700;
}

/* === Table Container === */
.table-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    margin-bottom: 16px;
}

/* === Table Styles === */
.documents-table {
    width: 100%;
    border-collapse: collapse;
}

.documents-table thead {
    background-color: #f9fafb;
    border-bottom: 2px solid #e5e7eb;
}

.documents-table th {
    padding: 9px 12px;
    text-align: left;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.documents-table tbody tr {
    border-bottom: 1px solid #e5e7eb;
    transition: background-color 0.2s;
}

.documents-table tbody tr:hover {
    background-color: #f9fafb;
}

.documents-table td {
    padding: 9px 12px;
    font-size: 14px;
    color: #374151;
}

.col-filing-date {
    white-space: nowrap;
    font-weight: 600;
    color: #1e3a8a;
}

.col-title {
    max-width: 500px;
}

.document-link {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 500;
    display: block;
    margin-bottom: 4px;
}

.document-link:hover {
    text-decoration: underline;
    color: #2563eb;
}

.case-number {
    font-size: 12px;
    color: #6b7280;
    font-family: 'Courier New', monospace;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-dct {
    background-color: #dbeafe;
    color: #1e40af;
}

.badge-itc {
    background-color: #fce7f3;
    color: #9f1239;
}

.badge-rit {
    background-color: #fef3c7;
    color: #92400e;
}

.badge-pto {
    background-color: #d1fae5;
    color: #065f46;
}

.badge-unknown {
    background-color: #f3f4f6;
    color: #6b7280;
}

.col-notes,
.col-tags {
    white-space: nowrap;
    text-align: center;
}

.notes-badge {
    padding: 3px 7px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.notes-yes {
    background-color: #dbeafe;
    color: #1e40af;
}

.notes-no {
    background-color: #f3f4f6;
    color: #9ca3af;
}

.tag-count-badge {
    display: inline-block;
    min-width: 22px;
    padding: 3px 6px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.tag-count-has {
    background-color: #fef3c7;
    color: #92400e;
}

.tag-count-none {
    background-color: #f3f4f6;
    color: #9ca3af;
}

.precedential-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.precedential-yes {
    background-color: #dcfce7;
    color: #166534;
}

.precedential-no {
    background-color: #f3f4f6;
    color: #6b7280;
}

.no-results {
    text-align: center;
    padding: 40px 20px !important;
    color: #9ca3af;
    font-style: italic;
}

/* === Pagination === */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px 0 8px;
}

.pagination-btn {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 6px;
    background: #1e3a8a;
    color: white;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.15s;
}

.pagination-btn:hover {
    background: #1e40af;
}

.pagination-disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: default;
    pointer-events: none;
}

.pagination-info {
    font-size: 14px;
    color: #374151;
}

/* === Footer === */
.footer {
    text-align: center;
    padding: 12px 20px;
    color: #6b7280;
    font-size: 14px;
}

/* === Mobile Responsive Styles === */
@media (max-width: 767px) {
    /* Mobile: Stack table as cards */
    .documents-table thead {
        display: none;
    }

    .documents-table,
    .documents-table tbody,
    .documents-table tr,
    .documents-table td {
        display: block;
        width: 100%;
    }

    .documents-table tr {
        margin-bottom: 20px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        overflow: hidden;
    }

    .documents-table td {
        padding: 12px 16px;
        border-bottom: 1px solid #f3f4f6;
        position: relative;
        padding-left: 40%;
    }

    .documents-table td:last-child {
        border-bottom: none;
    }

    .documents-table td:before {
        content: attr(data-label);
        position: absolute;
        left: 16px;
        top: 12px;
        font-weight: 700;
        font-size: 12px;
        color: #6b7280;
        text-transform: uppercase;
    }

    .col-title {
        max-width: none;
    }

    .container {
        padding: 8px 10px;
    }

    .header {
        padding: 10px 14px;
        margin: -8px -10px 12px;
        flex-direction: column;
        align-items: flex-start;
    }

    .header-brand {
        font-size: 16px;
    }

    .header-page {
        font-size: 15px;
    }

    .filters-section,
    .table-container {
        border-radius: 8px;
    }

    .filter-group {
        min-width: 100%;
    }
}

/* === iOS-specific optimizations === */
@supports (-webkit-touch-callout: none) {
    .filter-select,
    .btn {
        -webkit-appearance: none;
        appearance: none;
    }

    .filter-select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 40px;
    }
}

/* === Auth: Login page === */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 48px 16px;
}

.login-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 36px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.login-title {
    margin: 0 0 24px;
    font-size: 1.4rem;
    color: #1e3a8a;
    font-weight: 700;
}

.login-form .form-group {
    margin-bottom: 16px;
}

.login-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.btn-full {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

/* === Auth: Flash messages === */
.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin: 12px 0;
    font-size: 0.9rem;
    font-weight: 500;
}

.flash-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.flash-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.flash-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* === Auth: User badge in header === */
.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.role-tag {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* === Admin: forms and tables === */
.admin-form-section {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 24px;
    margin: 16px 0;
}

.admin-form-section h2 {
    margin: 0 0 20px;
    font-size: 1.1rem;
    color: #1e3a8a;
}

.admin-form-section h3 {
    margin: 0 0 16px;
    font-size: 1rem;
    color: #374151;
}

.admin-form .form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.admin-form .form-group {
    flex: 1;
    min-width: 200px;
    margin-bottom: 16px;
}

.admin-form label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.admin-divider {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 24px 0;
}

.admin-section {
    margin: 16px 0;
}

.admin-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.admin-section-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: #1e3a8a;
}

/* Role and status badges */
.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.role-badge.role-admin  { background: #ede9fe; color: #5b21b6; }
.role-badge.role-editor { background: #dbeafe; color: #1e40af; }
.role-badge.role-viewer { background: #f3f4f6; color: #6b7280; }

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-badge.status-active   { background: #dcfce7; color: #166534; }
.status-badge.status-inactive { background: #fee2e2; color: #991b1b; }

/* Annotation readonly view */
.annotation-readonly {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
}

.annotation-text-readonly {
    white-space: pre-wrap;
    font-family: inherit;
    font-size: 0.9rem;
    color: #374151;
    margin: 0 0 8px;
}

/* 403 page */
.error-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    text-align: center;
}

.error-card {
    padding: 40px;
}

.error-card h1 {
    font-size: 2.5rem;
    color: #1e3a8a;
    margin: 0 0 12px;
}

.error-card p {
    color: #6b7280;
    margin-bottom: 24px;
}

/* === Loading State === */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.loading::after {
    content: "Loading...";
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px 40px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-weight: 600;
    color: #1e3a8a;
}
