/* assets/css/style.css - Mobile-First Responsive Design */

/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1a3a5c;
    --primary-light: #2a5f8a;
    --primary-dark: #0f2640;
    --secondary: #2a7de1;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #343a40;
    --gray: #6c757d;
    --border: #dee2e6;
    --shadow: 0 2px 10px rgba(0,0,0,0.08);
    --radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f4f8;
    color: #333;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ===== NAVBAR - Mobile First ===== */
.navbar {
    background: var(--primary);
    color: white;
    padding: 0.8rem 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.nav-brand {
    font-size: 1.3rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    text-decoration: none;
}

.nav-brand i {
    font-size: 1.5rem;
}

/* Mobile Menu Toggle */
.nav-toggle {
    display: block;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 6px;
    transition: var(--transition);
}

.nav-toggle:hover {
    background: rgba(255,255,255,0.1);
}

.nav-menu {
    display: none;
    width: 100%;
    list-style: none;
    padding: 1rem 0 0.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: 0.8rem;
    flex-direction: column;
    gap: 0.3rem;
}

.nav-menu.active {
    display: flex;
}

.nav-menu a {
    color: white;
    text-decoration: none;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 0.95rem;
}

.nav-menu a:hover,
.nav-menu a.active {
    background: rgba(255,255,255,0.12);
}

.nav-menu a i {
    width: 1.5rem;
    text-align: center;
    font-size: 1.1rem;
}

/* ===== CONTAINER ===== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

/* ===== CARDS ===== */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.2rem;
    margin-bottom: 1.2rem;
    transition: var(--transition);
}

.card:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.card-header h3 {
    font-size: 1.1rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ===== BUTTONS - Touch Friendly ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--transition);
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-light);
    box-shadow: 0 4px 12px rgba(26, 58, 92, 0.3);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover {
    background: #218838;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-info:hover {
    background: #138496;
}

.btn-warning {
    background: var(--warning);
    color: var(--dark);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-sm {
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    min-height: 34px;
    min-width: 34px;
}

.btn-lg {
    padding: 0.8rem 2rem;
    font-size: 1.1rem;
}

/* ===== FORMS - Mobile Friendly ===== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    color: #555;
    margin-bottom: 0.4rem;
    font-size: 0.95rem;
}

.form-group label .required {
    color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
    background: white;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(42, 125, 225, 0.15);
}

.form-group input:invalid,
.form-group select:invalid {
    border-color: var(--danger);
}

.form-group .hint {
    font-size: 0.8rem;
    color: var(--gray);
    margin-top: 0.3rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

/* ===== TABLES - Mobile Responsive ===== */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    min-width: 600px;
}

.table th {
    background: var(--light);
    padding: 0.6rem 0.8rem;
    text-align: left;
    font-weight: 600;
    color: var(--gray);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.table td {
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table tr:hover {
    background: var(--light);
}

/* Mobile Card View for Tables */
@media (max-width: 768px) {
    .table {
        min-width: 100%;
        font-size: 0.85rem;
    }
    
    .table th,
    .table td {
        padding: 0.4rem 0.6rem;
    }
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: white;
    padding: 1.2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    transition: var(--transition);
}

.stat-card:active {
    transform: scale(0.98);
}

.stat-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--primary);
    flex-shrink: 0;
}

.stat-info h3 {
    font-size: 0.8rem;
    color: var(--gray);
    margin-bottom: 0.1rem;
    font-weight: 500;
}

.stat-info p {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-info small {
    font-size: 0.7rem;
    color: var(--gray);
}

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-active,
.badge-paid {
    background: #d4edda;
    color: #155724;
}

.badge-completed {
    background: #cce5ff;
    color: #004085;
}

.badge-defaulted,
.badge-overdue {
    background: #f8d7da;
    color: #721c24;
}

.badge-given {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-taken {
    background: #fff3cd;
    color: #856404;
}

.badge-pending {
    background: #fff3cd;
    color: #856404;
}

/* ===== ALERTS ===== */
.alert {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    font-size: 0.95rem;
}

.alert i {
    margin-top: 0.2rem;
    font-size: 1.2rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background: #cce5ff;
    color: #004085;
    border: 1px solid #b8daff;
}

/* ===== INTEREST PREVIEW ===== */
.interest-preview {
    background: var(--light);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1rem;
    border: 2px solid var(--border);
}

.interest-preview-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.8rem;
}

.interest-preview-item {
    background: white;
    padding: 0.8rem;
    border-radius: 8px;
    text-align: center;
}

.interest-preview-item .label {
    font-size: 0.7rem;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.interest-preview-item .value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

/* ===== LOGIN PAGE ===== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
}

.login-box {
    background: white;
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 400px;
}

.login-box h2 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-size: 1.8rem;
}

.login-box h2 i {
    color: var(--secondary);
}

.login-box h3 {
    text-align: center;
    color: var(--gray);
    font-weight: 400;
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

/* ===== PAGE HEADER ===== */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    color: var(--primary);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-header .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* ===== FILTER BAR ===== */
.filter-bar {
    margin-bottom: 1.2rem;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    align-items: center;
}

.filter-group label {
    font-weight: 500;
    color: var(--gray);
    font-size: 0.9rem;
}

.filter-group select,
.filter-group input {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
    flex: 1;
    min-width: 120px;
}

/* ===== LOAN EXAMPLES ===== */
.loan-type-examples {
    background: #e8f0fe;
    padding: 1rem;
    border-radius: 8px;
    margin: 1rem 0;
    border-left: 4px solid var(--secondary);
}

.loan-type-examples h4 {
    color: var(--primary);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.loan-type-examples ul {
    list-style: none;
    padding: 0;
}

.loan-type-examples li {
    padding: 0.3rem 0;
    font-size: 0.9rem;
    color: #555;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.loan-type-examples li i {
    color: var(--secondary);
}

/* ===== FOOTER ===== */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--gray);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
    font-size: 0.9rem;
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Small devices (phones, 576px and up) */
@media (min-width: 576px) {
    .form-row {
        grid-template-columns: 1fr 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .page-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .nav-toggle {
        display: none;
    }
    
    .nav-menu {
        display: flex !important;
        width: auto;
        border-top: none;
        padding: 0;
        margin: 0;
        flex-direction: row;
        gap: 0.5rem;
    }
    
    .nav-menu a {
        padding: 0.5rem 1rem;
    }
    
    .container {
        padding: 1.5rem 2rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .interest-preview-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
    
    .card {
        padding: 1.5rem;
    }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .container {
        padding: 2rem;
    }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    .container {
        padding: 2rem 3rem;
    }
}

/* ============================================
   TOUCH-FRIENDLY ENHANCEMENTS
   ============================================ */

/* Larger touch targets on mobile */
@media (max-width: 768px) {
    .btn {
        padding: 0.7rem 1.4rem;
        font-size: 1rem;
        min-height: 48px;
    }
    
    .btn-sm {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
        min-height: 38px;
    }
    
    input, select, textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    .stat-card {
        padding: 1rem;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .stat-info p {
        font-size: 1.1rem;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    :root {
        --light: #1a1a2e;
        --border: #2a2a4a;
        --shadow: 0 2px 10px rgba(0,0,0,0.3);
    }
    
    body {
        background: #0d0d1a;
        color: #e0e0e0;
    }
    
    .card,
    .stat-card,
    .login-box {
        background: #1a1a2e;
        color: #e0e0e0;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        background: #2a2a4a;
        color: #e0e0e0;
        border-color: #3a3a5a;
    }
    
    .table th {
        background: #2a2a4a;
        color: #aaa;
    }
    
    .table td {
        border-color: #2a2a4a;
    }
    
    .table tr:hover {
        background: #2a2a4a;
    }
    
    .interest-preview {
        background: #2a2a4a;
        border-color: #3a3a5a;
    }
    
    .interest-preview-item {
        background: #1a1a2e;
    }
    
    .loan-type-examples {
        background: #1a2a4a;
        border-left-color: var(--secondary);
    }
    
    .loan-type-examples li {
        color: #ccc;
    }
    
    .stat-info h3 {
        color: #aaa;
    }
    
    .stat-info p {
        color: #fff;
    }
    
    .alert-success {
        background: #1a3a2a;
        color: #8fdfb4;
        border-color: #2a5a3a;
    }
    
    .alert-error {
        background: #3a1a1a;
        color: #df8f8f;
        border-color: #5a2a2a;
    }
    
    .alert-info {
        background: #1a2a4a;
        color: #8fb4df;
        border-color: #2a4a6a;
    }
}