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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navigation */
.navbar {
    background-color: #2b8c8c;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand a {
    font-size: 1.5rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
    white-space: nowrap;
}

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

.nav-menu a {
    color: white;
    text-decoration: none;
    transition: color 0.3s;
    white-space: nowrap;
}

.nav-menu a:hover {
    color: #3498db;
}

.nav-menu a.active {
    color: #3498db;
    border-bottom: 2px solid #3498db;
    padding-bottom: 2px;
}

.nav-user {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn-logout {
    background-color: #e74c3c;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.btn-logout:hover {
    background-color: #c0392b;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 2rem;
}

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

.flash {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flash-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.flash-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.flash-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.5;
}

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

/* Forms */
.form-container {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-width: 600px;
    margin: 0 auto;
}

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
}

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

.required {
    color: #e74c3c;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

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

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

/* Cards */
.card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.card-header {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #ecf0f1;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #ecf0f1;
}

.table th {
    background-color: #2b8c8c;
    color: white;
    font-weight: 500;
}

.table tr:hover {
    background-color: #f8f9fa;
}

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

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.status-draft {
    background-color: #f39c12;
    color: white;
}

.status-ready {
    background-color: #3498db;
    color: white;
}

.status-signed {
    background-color: #27ae60;
    color: white;
}

.type-fa {
    background-color: #3498db;
    color: white;
}

.type-aor {
    background-color: #8e44ad;
    color: white;
}

/* Login Page */
.login-container {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-box {
    background: white;
    padding: 3rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 2rem;
    color: #2b8c8c;
}

/* Dashboard Grid */
.dashboard-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
}

.client-card {
    flex: 0 0 300px;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.client-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.client-name {
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #2b8c8c;
}

.client-info {
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.client-stats {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #ecf0f1;
}

.stat {
    font-size: 0.85rem;
}

.stat-label {
    color: #95a5a6;
}

.stat-value {
    font-weight: bold;
    color: #2b8c8c;
}

/* Global Client Search */
.search-wrapper {
    position: relative;
    list-style: none;
}

.search-input {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    color: white;
    font-size: 0.9rem;
    padding: 0.4rem 0.75rem;
    width: 200px;
    transition: background 0.2s, border-color 0.2s, width 0.3s;
    outline: none;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-input:focus {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.7);
    width: 260px;
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 320px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    z-index: 1000;
    overflow: hidden;
}

.search-result-card {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.15s;
}

.search-result-card:last-child {
    border-bottom: none;
}

.search-result-card:hover {
    background: #f0f6ff;
}

.search-result-name {
    font-size: 1rem;
    font-weight: 600;
    color: #2b8c8c;
    margin-bottom: 0.2rem;
}

.search-result-info {
    font-size: 0.8rem;
    color: #7f8c8d;
    margin-bottom: 0.4rem;
}

.search-result-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: #555;
}

.search-result-stats strong {
    color: #2b8c8c;
}

.search-no-results {
    padding: 0.75rem 1rem;
    color: #7f8c8d;
    font-size: 0.9rem;
    text-align: center;
}

/* Footer */
.footer {
    background-color: #2b8c8c;
    color: white;
    text-align: center;
    padding: 1rem;
    margin-top: auto;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }

.flex {
    display: flex;
}

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

.gap-1 { gap: 1rem; }
.gap-2 { gap: 2rem; }

/* Responsive utilities */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.client-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Tablet — iPad 8th gen portrait (768px) and landscape (1024px) */
@media (max-width: 1024px) {
    .nav-menu {
        gap: 0.75rem;
    }
    .search-input {
        width: 150px;
    }
    .search-input:focus {
        width: 180px;
    }
}

@media (max-width: 768px) {
    /* Keep navbar horizontal on iPad portrait — only stack on phones */
    .nav-menu {
        gap: 0.5rem;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    .search-input {
        width: 120px;
    }
    .search-input:focus {
        width: 140px;
    }
    .client-info-grid {
        grid-template-columns: 1fr;
    }
    /* Hide less-essential table columns on tablet */
    .hide-tablet {
        display: none !important;
    }
}

/* Phone — stack nav vertically */
@media (max-width: 480px) {
    .nav-container {
        flex-direction: column;
        gap: 1rem;
    }
    .nav-menu {
        flex-direction: column;
        gap: 0.5rem;
        justify-content: center;
    }
    .dashboard-grid {
        flex-direction: column;
        align-items: center;
    }
    .client-card {
        flex: 0 0 auto;
        width: 100%;
        max-width: 400px;
    }
}
