/* ===================================
   MOBILE-FIRST RESPONSIVE CSS
   =================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4361ee;
    --primary-dark: #3a0ca3;
    --success: #2ec4b6;
    --warning: #F39C12;
    --danger: #e63946;
    --income: #2ecc71;
    --expense: #e74c3c;
    --gray-light: #f8f9fa;
    --gray-medium: #dee2e6;
    --gray-dark: #343a40;
    --text-primary: #212529;
    --text-secondary: #7F8C8D;
    --border-color: #ECF0F1;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f9f9f9;
    color: var(--text-primary);
    overflow-x: hidden;
}

html, body {
    height: 100%;
    width: 100%;
}

/* ===== CONTAINER ===== */
.container {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    padding: 0;
    background-color: #fff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Tablet Layout */
@media (min-width: 768px) and (max-width: 1023px) {
    .container {
        max-width: 100%;
        width: 100%;
    }
    
    main {
        padding: 1.5rem;
        padding-bottom: 90px;
    }
}

/* Desktop Layout */
@media (min-width: 1024px) {
    .container {
        max-width: 100%;
        width: 100vw;
        display: grid;
        grid-template-columns: 250px 1fr;
        grid-template-rows: auto 1fr auto;
        gap: 0;
        margin: 0;
    }
    
    .navbar {
        grid-column: 1 / -1;
        grid-row: 1;
    }
    
    main {
        grid-column: 2;
        grid-row: 2;
        padding: 2rem;
        padding-bottom: 2rem;
        overflow-y: auto;
        max-height: calc(100vh - 150px);
    }
    
    .bottom-nav {
        grid-column: 1;
        grid-row: 2;
        display: flex;
        flex-direction: column;
        height: auto;
        border-right: 1px solid var(--border-color);
        border-top: none;
        position: static;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
    }
    
    .nav-item {
        border-radius: 10px;
        margin: 0.5rem;
        width: auto;
        justify-content: flex-start;
        padding: 0.8rem 1rem;
        flex-direction: row;
        gap: 1rem;
    }
    
    .nav-icon {
        margin-bottom: 0;
    }
}

/* ===== HEADER/NAVBAR ===== */
.navbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

@media (min-width: 1024px) {
    .navbar {
        padding: 2rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    }
    
    .navbar h1 {
        font-size: 1.8rem;
    }
    
    .navbar p {
        font-size: 1rem;
    }
}

.navbar h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.navbar p {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ===== MAIN CONTENT ===== */
main {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    padding-bottom: 80px;
}

@media (min-width: 1024px) {
    main {
        padding: 2rem;
        padding-bottom: 2rem;
    }
}

/* Dashboard Grid - Desktop */
@media (min-width: 1024px) {
    .summary-box.income {
        background: linear-gradient(135deg, var(--income) 0%, #218C53 100%);
    }
    
    .summary-box.expense {
        background: linear-gradient(135deg, var(--expense) 0%, #C0392B 100%);
    }
}

/* ===== CARD COMPONENT ===== */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary);
    transition: all 0.3s ease;
}

@media (min-width: 1024px) {
    .card {
        padding: 1.5rem;
        margin-bottom: 1.2rem;
        border-left-width: 5px;
        border-radius: 12px;
    }
    
    .card:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.12);
        transform: translateY(-2px);
    }
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.card-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.card-amount {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--primary);
}

.card-amount.positive {
    color: var(--success);
}

.card-amount.negative {
    color: var(--danger);
}

.card-subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.8rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.card-category {
    display: inline-block;
    background-color: var(--gray-light);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
}

/* ===== SUMMARY BOX ===== */
.summary-box {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1.5rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px rgba(46, 134, 222, 0.2);
}

@media (min-width: 768px) {
    .summary-box {
        padding: 2rem;
    }
}

@media (min-width: 1024px) {
    .summary-box {
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 2rem;
        margin-bottom: 0;
        height: 100%;
    }
}

.summary-item {
    margin-bottom: 1rem;
}

.summary-item:last-child {
    margin-bottom: 0;
}

.summary-label {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 0.3rem;
}

.summary-value {
    font-size: 1.8rem;
    font-weight: bold;
}

.summary-income {
    background: linear-gradient(135deg, var(--income) 0%, #218C53 100%);
}

.summary-expense {
    background: linear-gradient(135deg, var(--expense) 0%, #C0392B 100%);
}

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

@media (min-width: 1024px) {
    .summary-grid {
        grid-template-columns: 1fr;
        margin-top: 0;
    }
}

.summary-item-small {
    background: rgba(255,255,255,0.2);
    padding: 0.8rem;
    border-radius: 8px;
}

.summary-item-small .summary-label {
    font-size: 0.8rem;
}

.summary-item-small .summary-value {
    font-size: 1.2rem;
}

/* ===== FORM ELEMENTS ===== */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-primary);
}

input, select, textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1.5px solid var(--gray-medium);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s, box-shadow 0.3s;
    background-color: #fff;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46, 134, 222, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    width: 100%;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.btn-secondary {
    background-color: var(--gray-medium);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: #d8d8d8;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover {
    background-color: #40B856;
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #EE5A52;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    display: inline-block;
    width: auto;
}

.btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

/* ===== FLOATING ACTION BUTTON ===== */
.fab {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    z-index: 99;
    text-decoration: none;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(255, 107, 107, 0.4);
}

.fab:active {
    transform: scale(0.95);
}

@media (min-width: 1024px) {
    .fab {
        display: none;
    }
}

/* ===== BOTTOM NAVIGATION ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 70px;
    max-width: 480px;
    margin: 0 auto;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: all 0.3s;
}

.nav-item:hover, .nav-item.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 1.5rem;
    margin-bottom: 0.3rem;
}

@media (min-width: 1024px) {
    .bottom-nav {
        position: static;
        height: auto;
        max-width: 100%;
        border-top: none;
        flex-direction: column;
    }
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 200;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    animation: fadeIn 0.3s;
}

.modal.show {
    display: flex;
    align-items: flex-end;
}

.modal-content {
    background-color: white;
    width: 100%;
    max-width: 480px;
    margin: auto;
    padding: 1.5rem;
    border-radius: 15px 15px 0 0;
    animation: slideUp 0.3s;
    max-height: 80vh;
    overflow-y: auto;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-title {
    font-size: 1.3rem;
    font-weight: bold;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

/* ===== ALERT ===== */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
    animation: slideDown 0.3s;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.empty-text {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.empty-subtext {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* ===== FILTER ===== */
.filter-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color);
    background-color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-btn:hover, .filter-btn.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== LOADING ===== */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--gray-medium);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-box {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
}

/* ===== PAGINATION ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 1.5rem 0;
}

.pagination a, .pagination span {
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s;
}

.pagination a:hover {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination .active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ===== SUMMARY BOXES RESPONSIVE ===== */
.summary-boxes-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (min-width: 768px) {
    .summary-boxes-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 1024px) {
    .summary-boxes-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1.5rem;
    }
}

/* ===== ACTION BUTTONS RESPONSIVE ===== */
.action-buttons-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (min-width: 600px) {
    .action-buttons-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ===== STAT ROW RESPONSIVE (for profil.php) ===== */
.stat-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (min-width: 600px) {
    .stat-row {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 1024px) {
    .stat-row {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* ===== CATEGORY/SOURCE GRID RESPONSIVE ===== */
.kategori-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 600px) {
    .kategori-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.sumber-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 600px) {
    .sumber-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    .container {
        max-width: 100%;
    }

    main {
        padding: 1rem 0.8rem;
    }

    .btn {
        padding: 0.7rem;
    }

    .card {
        padding: 0.8rem;
    }
}

@media (min-width: 601px) and (max-width: 1023px) {
    .container {
        max-width: 100%;
    }

    .summary-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 100vw;
    }
}

/* ===== UTILITY ===== */
.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; }

.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }

.hidden {
    display: none;
}

.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.text-muted {
    color: var(--text-secondary);
}

.text-success {
    color: var(--success);
}

.text-danger {
    color: var(--danger);
}

.text-primary {
    color: var(--primary);
}

/* ===== TOAST NOTIFICATION ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    border-left: 5px solid var(--primary);
    animation: toastSlideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    transition: all 0.4s ease;
}

.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

@keyframes toastSlideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
