/* ========================================
   Performance Review Portal - Main Styles
   ======================================== */

/* CSS Variables */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;

    --bg-color: #ffffff;
    --bg-secondary: #f8fafc;
    --text-color: #0f172a;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --border-radius: 0.375rem;
    --box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --transition: all 0.2s ease;
}

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

body {
    font-family: var(--font-family);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-secondary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Navigation */
.navbar {
    background-color: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    box-shadow: var(--box-shadow);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-logo {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
    text-decoration: none;
}

.navbar-menu {
    display: flex;
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--primary-color);
}

/* Mobile menu toggle button */
.navbar-toggle {
    display: none;
    flex-direction: column;
    gap: 0.25rem;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    margin-left: auto;
}

.navbar-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--text-color);
    transition: var(--transition);
}

.navbar-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.navbar-toggle.active span:nth-child(2) {
    opacity: 0;
}

.navbar-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.navbar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 0;
}

/* Flash Messages */
.flash-messages {
    margin-top: 1rem;
}

.flash-messages:empty {
    margin: 0;
}

.alert {
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #10b981;
}

.alert-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #3b82f6;
}

.alert-warning {
    background-color: #fef3c7;
    color: #92400e;
    border: 1px solid #f59e0b;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #ef4444;
}

.alert-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    transition: var(--transition);
}

.alert-close:hover {
    opacity: 1;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

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

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-outline:hover {
    background-color: var(--bg-secondary);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 0.625rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.form-error {
    color: var(--danger-color);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Cards */
.card {
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.card-body {
    padding: 1rem 0;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    overflow: hidden;
}

.table th,
.table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background-color: var(--bg-secondary);
    font-weight: 600;
}

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

.table tr:hover {
    background-color: var(--bg-secondary);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 9999px;
}

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

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

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

.badge-secondary {
    background-color: #f1f5f9;
    color: #475569;
}

/* Loading Spinner */
.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer */
.footer {
    background-color: var(--bg-color);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: auto;
    text-align: center;
    color: var(--text-secondary);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.hidden { display: none; }

/* ========================================
   Responsive Design
   ======================================== */

/* Mobile First - Small devices (portrait phones, less than 576px) */
/* Base styles above are mobile-first */

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .container {
        max-width: 540px;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }

    body {
        font-size: 16px;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .container {
        max-width: 960px;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        max-width: 1140px;
    }
}

/* Mobile Specific Styles (max-width: 768px) */
@media (max-width: 768px) {
    /* Typography adjustments */
    body {
        font-size: 14px;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    /* Navigation - Stack vertically on mobile */
    .navbar {
        padding: 0.75rem 0;
    }

    .navbar .container {
        flex-direction: column;
        gap: 0;
        align-items: stretch;
    }

    .navbar-brand {
        justify-content: space-between;
    }

    .navbar-toggle {
        display: flex;
    }

    .navbar-menu {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-out;
        width: 100%;
    }

    .navbar-menu.active {
        max-height: 500px;
        transition: max-height 0.5s ease-in;
    }

    .navbar-nav {
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
        padding-top: 1rem;
    }

    .nav-item {
        width: 100%;
    }

    .nav-link {
        display: block;
        padding: 0.5rem 1rem;
        text-align: center;
        border-radius: var(--border-radius);
        background-color: var(--bg-secondary);
    }

    /* Main content - Reduce padding */
    .main-content {
        padding: 1rem 0;
    }

    /* Cards - Reduce padding */
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    .card-header {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
    }

    .card-body {
        padding: 0.5rem 0;
    }

    /* Tables - Make scrollable horizontally */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        font-size: 0.8125rem;
        min-width: 600px; /* Ensure table doesn't collapse too much */
    }

    .table th,
    .table td {
        padding: 0.5rem 0.375rem;
        white-space: nowrap;
    }

    /* Buttons - Stack vertically when needed */
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .btn-group .btn {
        width: 100%;
    }

    /* Forms - Full width */
    .form-group {
        margin-bottom: 1rem;
    }

    .form-control {
        font-size: 16px; /* Prevent zoom on iOS */
    }

    /* Action buttons in tables */
    .table .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.8125rem;
    }

    /* Badges - Smaller */
    .badge {
        font-size: 0.75rem;
        padding: 0.2rem 0.5rem;
    }

    /* Alert messages */
    .alert {
        padding: 0.75rem;
        font-size: 0.875rem;
    }

    /* Footer */
    .footer {
        padding: 1.5rem 0;
        font-size: 0.875rem;
    }

    /* Export buttons - Stack on mobile */
    .export-buttons {
        flex-direction: column;
        width: 100%;
        margin-top: 0.5rem;
    }

    .export-buttons .btn {
        width: 100%;
        justify-content: center;
    }

    /* Page headers with actions */
    .page-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 1rem;
    }

    .header-actions {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .header-actions .btn {
        width: 100%;
    }

    /* Card headers with actions */
    .card-header[style*="display: flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem;
    }

    /* Filter controls */
    .filter-controls {
        flex-direction: column;
        align-items: stretch !important;
    }

    .filter-controls select,
    .filter-controls .form-control {
        max-width: 100% !important;
    }

    /* Summary stats grid */
    .summary-stats {
        grid-template-columns: 1fr !important;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 2rem;
    }
}

/* Extra small devices (portrait phones, max-width: 576px) */
@media (max-width: 576px) {
    /* Further reduce spacing */
    .container {
        padding: 0 0.75rem;
    }

    .card {
        padding: 0.75rem;
        border-radius: 0.25rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }

    /* Tables - Even more compact */
    .table {
        font-size: 0.75rem;
    }

    .table th,
    .table td {
        padding: 0.375rem 0.25rem;
    }

    /* Rating stars - Smaller */
    .rating-stars {
        font-size: 1rem;
    }

    /* Modals - Full screen on very small devices */
    .modal {
        padding: 0;
    }

    .modal-content {
        border-radius: 0;
        min-height: 100vh;
    }
}

/* Landscape orientation optimizations */
@media (max-height: 600px) and (orientation: landscape) {
    .navbar {
        padding: 0.5rem 0;
    }

    .main-content {
        padding: 1rem 0;
    }

    .card {
        margin-bottom: 1rem;
    }
}

/* Print styles */
@media print {
    .navbar,
    .footer,
    .btn,
    .alert-close,
    .export-buttons {
        display: none !important;
    }

    .main-content {
        padding: 0;
    }

    .card {
        box-shadow: none;
        border: 1px solid #000;
        page-break-inside: avoid;
    }

    .table {
        page-break-inside: auto;
    }

    .table tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .btn,
    .nav-link,
    .form-control {
        min-height: 44px; /* Apple's recommended minimum touch target */
    }

    /* Remove hover effects on touch devices */
    .table tr:hover {
        background-color: transparent;
    }
}
