/* =============================================================================
   MA Contract Management System - Main Stylesheet
   Version: 1.0 - Enhanced
   ============================================================================= */

/* CSS Variables */
:root {
    --color-bg: #f4f6fb;
    --color-surface: #ffffff;
    --color-primary: #1f7aec;
    --color-primary-dark: #145ab8;
    --color-primary-light: #60a5fa;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-secondary: #6b7280;
    --color-text: #1f2937;
    --color-text-light: #4b5563;
    --color-muted: #6b7280;
    --color-border: #e5e7eb;
    --sidebar-width: 240px;
    --transition-speed: 0.2s;
    --border-radius: 12px;
    --border-radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.08);
    font-size: 16px;
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.app {
    margin: 0;
    background-color: var(--color-bg);
}

/* Links */
a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-speed);
}

a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

/* App Shell Layout */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.app-sidebar {
    width: var(--sidebar-width);
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
}

.app-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}

.app-logo {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
    font-weight: 700;
    font-size: 1.2rem;
    color: white;
}

.app-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #ffffff;
}

.app-sidebar__nav {
    flex: 1;
    overflow-y: auto;
}

.app-sidebar__nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.app-sidebar__nav li a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    color: #cbd5e1;
    transition: all var(--transition-speed);
    font-size: 0.95rem;
}

.app-sidebar__nav li.active a,
.app-sidebar__nav li a:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    text-decoration: none;
    transform: translateX(4px);
}

.app-sidebar__nav .icon {
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
}

/* Content Area */
.app-shell__content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Topbar */
.app-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 90;
}

.app-topbar__left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.app-topbar__title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
}

.app-topbar__right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    border-radius: 10px;
    background: var(--color-bg);
}

.user-menu__name {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
}

.user-menu__name strong {
    font-weight: 600;
    color: var(--color-text);
}

.user-menu__role {
    font-size: 0.75rem;
    color: var(--color-muted);
    text-transform: capitalize;
}

/* Main Content */
.app-main {
    flex: 1;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* Dashboard */
.dashboard {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1rem;
}

/* Stat Cards */
.stat-card {
    background: var(--color-surface);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
}

.stat-card__label {
    font-size: 0.875rem;
    color: var(--color-muted);
    font-weight: 500;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card__value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-text);
    margin-top: 0.5rem;
    line-height: 1;
}

/* Table Card */
.table-card {
    background: var(--color-surface);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.table-card h2 {
    margin: 0 0 1.5rem 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
}

.table-card table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table-card thead {
    background: var(--color-bg);
}

.table-card th,
.table-card td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.table-card th {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05rem;
    color: var(--color-muted);
    font-weight: 600;
}

.table-card tbody tr {
    transition: background var(--transition-speed);
}

.table-card tbody tr:hover {
    background: var(--color-bg);
}

.table-card tbody tr:last-child td {
    border-bottom: none;
}

.table-card td a {
    color: var(--color-primary);
    font-weight: 500;
}

.table-card td a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
    border-radius: 10px;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    text-decoration: none;
    font-family: inherit;
    white-space: nowrap;
}

.btn:hover {
    text-decoration: none;
    transform: translateY(-2px);
}

.btn-primary {
    background: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(31, 122, 236, 0.3);
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    box-shadow: 0 4px 12px rgba(31, 122, 236, 0.4);
}

.btn-secondary {
    background: var(--color-secondary);
    color: #ffffff;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-success {
    background: var(--color-success);
    color: #ffffff;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--color-danger);
    color: #ffffff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-link {
    background: transparent;
    color: var(--color-primary);
    padding: 0.5rem 0.75rem;
    box-shadow: none;
}

.btn-link:hover {
    background: rgba(31, 122, 236, 0.1);
    color: var(--color-primary-dark);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-secondary {
    background: #e5e7eb;
    color: #374151;
}

/* Empty State */
.table-card p {
    color: var(--color-muted);
    font-size: 0.95rem;
    text-align: center;
    margin: 0;
}

.table-card p a {
    color: var(--color-primary);
    font-weight: 500;
}

/* Notifications Icon */
.notification-icon {
    position: relative;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--color-text-light);
    padding: 0.5rem;
    border-radius: 8px;
    transition: all var(--transition-speed);
}

.notification-icon:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.notification-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--color-danger);
    color: white;
    border-radius: 999px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 600;
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--color-muted);
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--color-muted);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

/* Responsive Design */
@media (max-width: 1024px) {
    .app-sidebar {
        position: fixed;
        left: -100%;
        transition: left var(--transition-speed);
    }

    .app-sidebar.is-open {
        left: 0;
    }

    .app-shell__content {
        margin-left: 0;
    }

    .dashboard-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .app-main {
        padding: 1rem;
    }

    .app-topbar {
        padding: 1rem;
    }

    .app-topbar__title {
        font-size: 1.25rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-card__value {
        font-size: 2rem;
    }

    .table-card {
        padding: 1rem;
        overflow-x: auto;
    }

    .table-card table {
        min-width: 600px;
    }

    .user-menu__name {
        display: none;
    }
}

@media (max-width: 480px) {
    .stat-card__value {
        font-size: 1.75rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
}

/* Print Styles */
@media print {
    .app-sidebar,
    .app-topbar,
    .btn {
        display: none;
    }

    .app-shell__content {
        margin-left: 0;
    }

    .app-main {
        padding: 0;
    }

    .table-card,
    .stat-card {
        box-shadow: none;
        border: 1px solid var(--color-border);
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Focus States for Accessibility */
.btn:focus,
a:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-muted);
}