/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1E3A5F;
    --primary-dark: #0F1C2E;
    --primary-light: #2C5282;
    --secondary-color: #3B82F6;
    --danger-color: #DC2626;
    --warning-color: #F59E0B;
    --text-primary: #E5E7EB;
    --text-secondary: #9CA3AF;
    --bg-primary: #0F172A;
    --bg-secondary: #1E293B;
    --bg-tertiary: #334155;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    line-height: 1.6;
}

/* Login Page Styles */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1E3A5F 0%, #0F172A 100%);
}

.login-container {
    width: 100%;
    max-width: 450px;
    padding: 2rem;
}

.login-box {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 3rem 2.5rem;
    box-shadow: var(--shadow-xl);
    text-align: center;
    border: 1px solid var(--border-color);
}

.logo {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.logo img {
    object-fit: contain;
    background: transparent;
    mix-blend-mode: normal;
}

.login-box h1 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #3B82F6 0%, #60A5FA 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.error-message {
    background-color: rgba(220, 38, 38, 0.2);
    color: #FCA5A5;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid rgba(220, 38, 38, 0.3);
}

.btn-primary {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, #1E3A5F 0%, #2C5282 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2C5282 0%, #3B82F6 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    padding: 0.875rem 1.5rem;
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background-color: var(--border-color);
    border-color: var(--text-secondary);
}

.login-footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.login-footer p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Dashboard Styles */
.dashboard-page {
    background-color: var(--bg-primary);
}

.dashboard-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 100%;
    background: linear-gradient(135deg, #1E3A5F 0%, #0F172A 100%);
    color: white;
    display: flex;
    flex-direction: row;
    box-shadow: var(--shadow-lg);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header {
    padding: 1rem 1.5rem;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 250px;
}

.logo-small {
    display: flex;
    justify-content: center;
}

.logo-small svg {
    width: 60px;
    height: 60px;
}

.logo-small img {
    object-fit: contain;
    background: transparent;
    mix-blend-mode: normal;
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
}

.sidebar-nav {
    flex: 1;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    white-space: nowrap;
    font-size: 0.9rem;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
    border-bottom-color: white;
}

.toggle-menu-btn {
    display: none;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
}

.btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background-color: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

.btn-logout:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    width: 100%;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.content-header h1 {
    font-size: 2rem;
    color: var(--text-primary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-name {
    color: var(--text-secondary);
    font-weight: 500;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1E3A5F 0%, #3B82F6 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
    border: 2px solid var(--border-color);
}

/* Content Sections */
.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

/* Card */
.card {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.card-compact {
    padding: 1.6rem;
}

.card-compact .form-group label {
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
}

.card-compact .form-group input,
.card-compact .form-group select,
.card-compact .form-group textarea {
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
}

.card-compact .form-row {
    gap: 1.2rem;
    margin-bottom: 1.2rem;
}

.card-compact .form-actions {
    margin-top: 1.6rem;
}

.card-compact .btn-primary,
.card-compact .btn-secondary {
    padding: 0.7rem 1.2rem;
    font-size: 0.9rem;
}

/* Form Styles */
.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.form-actions .btn-primary {
    width: auto;
}

/* Search Box */
.search-box {
    position: relative;
    width: 300px;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
}

.search-box svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* Table Styles */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background-color: var(--bg-tertiary);
}

th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    font-size: 0.9rem;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

tbody tr {
    transition: background-color 0.2s ease;
}

tbody tr:hover {
    background-color: var(--bg-tertiary);
}

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.375rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-valid {
    background-color: rgba(16, 185, 129, 0.2);
    color: #34D399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-expiring {
    background-color: rgba(245, 158, 11, 0.2);
    color: #FBBF24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-expired {
    background-color: rgba(220, 38, 38, 0.2);
    color: #FCA5A5;
    border: 1px solid rgba(220, 38, 38, 0.3);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    padding: 0.5rem;
    background-color: transparent;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background-color: var(--bg-tertiary);
    color: var(--secondary-color);
}

.btn-icon.delete:hover {
    color: var(--danger-color);
}

/* Responsive Design */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    
    .main-content {
        margin-left: 240px;
        padding: 1.5rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chart-container {
        min-height: 200px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        flex-wrap: wrap;
        padding: 0;
    }
    
    .sidebar-header {
        padding: 0.5rem 0.75rem;
        min-width: auto;
        flex: 0 0 auto;
        border-right: none;
        gap: 0.5rem;
    }
    
    .logo-small svg {
        width: 40px;
        height: 40px;
    }
    
    .sidebar-header h2 {
        font-size: 0.85rem;
        display: none;
    }
    
    .datetime-display {
        display: none;
    }
    
    .sidebar-nav {
        flex: 1 1 auto;
        padding: 0.5rem 0.25rem;
        overflow-x: auto;
        gap: 0.1rem;
        -webkit-overflow-scrolling: touch;
        display: flex;
        align-items: center;
    }
    
    .nav-item {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        flex-shrink: 0;
        gap: 0.25rem;
        border-bottom: 2px solid transparent;
    }
    
    .nav-item span {
        display: none;
    }
    
    .nav-item svg {
        width: 18px;
        height: 18px;
    }
    
    .nav-item.active {
        border-bottom-color: white;
    }
    
    .sidebar-footer {
        padding: 0.5rem 0.75rem;
        border-left: none;
        flex: 0 0 auto;
    }
    
    .btn-logout {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
        gap: 0.3rem;
    }
    
    .btn-logout span {
        display: none;
    }
    
    .btn-logout svg {
        width: 18px;
        height: 18px;
    }
    
    .main-content {
        margin-left: 0;
        padding: 1rem;
        width: 100%;
        max-width: 100%;
    }
    
    .content-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .content-header h1 {
        font-size: 1.5rem;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .section-header h2 {
        font-size: 1.25rem;
    }
    
    .search-box {
        width: 100%;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn-primary,
    .form-actions .btn-secondary {
        width: 100%;
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 800px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 1.25rem;
    }
    
    .stat-value {
        font-size: 1.75rem;
    }
    
    .chart-container {
        min-height: 180px;
        padding: 0.75rem;
    }
    
    .bar-label {
        font-size: 0.65rem;
    }
    
    .card {
        padding: 1.5rem;
        width: 100%;
        box-sizing: border-box;
    }
    
    .card-compact {
        padding: 1.2rem;
    }
}

@media (max-width: 480px) {
    .login-container {
        padding: 1rem;
    }
    
    .login-box {
        padding: 2rem 1.5rem;
    }
    
    .login-box h1 {
        font-size: 1.5rem;
    }
    
    .logo svg {
        width: 150px;
        height: 150px;
    }
    
    .sidebar-header {
        padding: 1rem;
    }
    
    .logo-small svg {
        width: 70px;
        height: 70px;
    }
    
    .sidebar-header h2 {
        font-size: 1rem;
    }
    
    .nav-item {
        flex: 1 1 100%;
        font-size: 0.9rem;
    }
    
    .nav-item svg {
        width: 18px;
        height: 18px;
    }
    
    .main-content {
        padding: 0.75rem;
    }
    
    .content-header h1 {
        font-size: 1.25rem;
    }
    
    .section-header h2 {
        font-size: 1.1rem;
    }
    
    .card {
        padding: 1rem;
        border-radius: 8px;
    }
    
    .form-group label {
        font-size: 0.85rem;
    }
    
    .form-group input,
    .form-group select {
        padding: 0.65rem 0.85rem;
        font-size: 0.95rem;
    }
    
    .btn-primary,
    .btn-secondary {
        padding: 0.75rem 1.25rem;
        font-size: 0.95rem;
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
    }
    
    .stat-icon svg {
        width: 20px;
        height: 20px;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    .chart-container {
        min-height: 150px;
        padding: 0.5rem;
        gap: 0.25rem;
    }
    
    .bar-value {
        font-size: 0.65rem;
    }
    
    .bar-label {
        font-size: 0.6rem;
        bottom: -20px;
    }
    
    th, td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }
    
    .status-badge {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .btn-icon {
        padding: 0.4rem;
    }
    
    .btn-icon svg {
        width: 16px;
        height: 16px;
    }
}

/* Landscape orientation for tablets */
@media (max-width: 1024px) and (orientation: landscape) {
    .sidebar {
        width: 200px;
    }
    
    .main-content {
        margin-left: 200px;
    }
    
    .sidebar-nav {
        padding: 1rem 0;
    }
    
    .nav-item {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .btn-logout,
    .form-actions,
    .action-buttons,
    .search-box {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0;
        padding: 0;
    }
    
    .card {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
    
    table {
        page-break-inside: auto;
    }
    
    tr {
        page-break-inside: avoid;
        page-break-after: auto;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.3s ease;
}

/* DateTime Display */
.datetime-display {
    margin-left: auto;
    padding-left: 1rem;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.date-text {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.75rem;
    margin-bottom: 0.15rem;
}

.time-text {
    color: #60A5FA;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* Statistics Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-info {
    flex: 1;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.stat-value {
    color: var(--text-primary);
    font-size: 2rem;
    font-weight: 700;
}

/* Charts */
.chart-container {
    min-height: 250px;
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 8px;
}

.chart-bar {
    flex: 1;
    background: linear-gradient(180deg, #3B82F6 0%, #2563EB 100%);
    border-radius: 4px 4px 0 0;
    min-height: 20px;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    transition: all 0.3s ease;
    cursor: pointer;
}

.chart-bar:hover {
    background: linear-gradient(180deg, #60A5FA 0%, #3B82F6 100%);
    transform: scaleY(1.05);
}

.bar-value {
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.bar-label {
    position: absolute;
    bottom: -25px;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* SMS Log */
.sms-log-entry {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.sms-log-entry p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.sms-log-entry strong {
    color: var(--text-primary);
}

.sms-log-entry ul {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.sms-log-entry ul li {
    margin-bottom: 0.25rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}
