/**
 * Custom Styles for Fatura Ödeme Takip Sistemi
 * Main stylesheet for the application
 * Mobile-first responsive design
 */

/* ========================================
   CSS Variables & Color Scheme
   ======================================== */
:root {
    --primary-color: #0d6efd;
    --primary-dark: #0a58ca;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --light-bg: #f8f9fa;
    --dark-text: #212529;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-600: #6c757d;
    --white: #ffffff;
    --border-radius: 0.375rem;
    --border-radius-lg: 0.5rem;
    --box-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --transition-base: all 0.2s ease-in-out;
}

/* ========================================
   Global Styles & Typography
   ======================================== */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--dark-text);
    background-color: var(--light-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container-fluid {
    flex: 1 0 auto;
}

.footer {
    flex-shrink: 0;
}

/* Typography - Mobile First */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.5rem;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.125rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

/* Desktop Typography */
@media (min-width: 768px) {
    h1 { font-size: 2.5rem; }
    h2 { font-size: 2rem; }
    h3 { font-size: 1.75rem; }
    h4 { font-size: 1.5rem; }
    h5 { font-size: 1.25rem; }
    h6 { font-size: 1rem; }
}

p {
    margin-bottom: 1rem;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition-base);
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* ========================================
   Utility Classes
   ======================================== */
.gradient-bg {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.text-muted {
    color: var(--gray-600) !important;
}

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }

/* ========================================
   Container & Layout
   ======================================== */
.container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

@media (min-width: 576px) {
    .container { max-width: 540px; }
}

@media (min-width: 768px) {
    .container { max-width: 720px; }
}

@media (min-width: 992px) {
    .container { max-width: 960px; }
}

@media (min-width: 1200px) {
    .container { max-width: 1140px; }
}

/* ========================================
   Buttons - Touch-Friendly (Mobile First)
   ======================================== */
.btn {
    display: inline-block;
    font-weight: 400;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    user-select: none;
    border: 1px solid transparent;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: var(--border-radius);
    transition: var(--transition-base);
    cursor: pointer;
    /* Touch-friendly minimum size */
    min-height: 44px;
    min-width: 44px;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--box-shadow-sm);
}

.btn:active {
    transform: translateY(0);
}

.btn:focus {
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.btn-primary {
    color: var(--white);
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-success {
    color: var(--white);
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-danger {
    color: var(--white);
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

.btn-info {
    color: var(--white);
    background-color: var(--info-color);
    border-color: var(--info-color);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    min-height: 38px;
    min-width: 38px;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.125rem;
    min-height: 50px;
}

/* Full-width buttons on mobile */
@media (max-width: 576px) {
    .btn-block-mobile {
        display: block;
        width: 100%;
    }
}

/* Desktop button sizes */
@media (min-width: 768px) {
    .btn {
        min-height: auto;
        min-width: auto;
        padding: 0.375rem 0.75rem;
    }
    
    .btn-sm {
        min-height: auto;
        min-width: auto;
    }
}

/* ========================================
   Forms - Touch-Friendly Inputs
   ======================================== */
.form-control,
.form-select {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--dark-text);
    background-color: var(--white);
    background-clip: padding-box;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    /* Touch-friendly minimum height */
    min-height: 44px;
}

.form-control:focus,
.form-select:focus {
    color: var(--dark-text);
    background-color: var(--white);
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.95rem;
}

.form-group {
    margin-bottom: 1rem;
}

/* Form validation styles */
.is-invalid {
    border-color: var(--danger-color);
}

.is-invalid:focus {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25);
}

.invalid-feedback {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--danger-color);
}

/* Checkbox and radio - touch-friendly */
input[type="checkbox"],
input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

@media (max-width: 576px) {
    input[type="checkbox"],
    input[type="radio"] {
        width: 24px;
        height: 24px;
    }
}

/* Desktop form sizes */
@media (min-width: 768px) {
    .form-control,
    .form-select {
        padding: 0.375rem 0.75rem;
        min-height: auto;
    }
}

/* ========================================
   Cards - Dashboard & Content
   ======================================== */
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    word-wrap: break-word;
    background-color: var(--white);
    background-clip: border-box;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-sm);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-bottom: 1.5rem;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--box-shadow);
}

.card-header {
    padding: 1rem 1.25rem;
    margin-bottom: 0;
    background-color: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.card-body {
    flex: 1 1 auto;
    padding: 1.25rem;
}

.card-footer {
    padding: 1rem 1.25rem;
    background-color: var(--gray-100);
    border-top: 1px solid var(--gray-200);
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

.card-title {
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
}

/* Statistics Cards */
.card-body h3 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.card-body h2 {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

@media (min-width: 768px) {
    .card-body h3 {
        font-size: 2rem;
    }
    
    .card-body h2 {
        font-size: 2.5rem;
    }
}

/* Icon opacity */
.opacity-50 {
    opacity: 0.5;
}

/* ========================================
   Mobile Card Layout for Tables
   ======================================== */
.invoice-card {
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius-lg);
    margin-bottom: 1rem;
    box-shadow: var(--box-shadow-sm);
    overflow: hidden;
}

.invoice-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: var(--gray-100);
    border-bottom: 1px solid var(--gray-300);
}

.invoice-card .card-body {
    padding: 1rem;
}

.invoice-card .card-body .row {
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
}

.invoice-card .card-body .row:last-child {
    margin-bottom: 0;
}

.invoice-card .card-footer {
    padding: 0.75rem 1rem;
    background-color: var(--gray-100);
    border-top: 1px solid var(--gray-300);
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 1rem;
}

.status-paid {
    background-color: #d1e7dd;
    color: #0f5132;
}

.status-unpaid {
    background-color: #f8d7da;
    color: #842029;
}

/* Hide mobile cards on desktop */
@media (min-width: 768px) {
    #invoiceCards {
        display: none;
    }
}

/* Hide desktop table on mobile */
@media (max-width: 767px) {
    .table-responsive {
        display: none;
    }
}

/* Responsive chart containers */
canvas {
    max-height: 250px;
    width: 100% !important;
}

@media (min-width: 768px) {
    canvas {
        max-height: 300px;
    }
}

/* ========================================
   Navigation - Mobile First
   ======================================== */
.navbar {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background-color: var(--white);
    box-shadow: var(--box-shadow-sm);
}

.navbar-brand {
    display: inline-block;
    padding-top: 0.3125rem;
    padding-bottom: 0.3125rem;
    margin-right: 1rem;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: inherit;
    white-space: nowrap;
    color: var(--primary-color);
}

@media (min-width: 768px) {
    .navbar-brand {
        font-size: 1.25rem;
    }
}

.navbar-nav {
    display: flex;
    flex-direction: column;
    padding-left: 0;
    margin-bottom: 0;
    list-style: none;
}

@media (min-width: 768px) {
    .navbar-nav {
        flex-direction: row;
    }
}

.nav-link {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--dark-text);
    text-decoration: none;
    transition: var(--transition-base);
    /* Touch-friendly */
    min-height: 44px;
    display: flex;
    align-items: center;
}

.nav-link:hover,
.nav-link:focus {
    color: var(--primary-color);
    background-color: var(--gray-100);
    border-radius: var(--border-radius);
}

.nav-link.active {
    color: var(--primary-color);
    font-weight: 600;
}

/* Mobile menu toggle */
.navbar-toggler {
    padding: 0.5rem 0.75rem;
    font-size: 1.25rem;
    line-height: 1;
    background-color: transparent;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    cursor: pointer;
    /* Touch-friendly */
    min-height: 44px;
    min-width: 44px;
}

.navbar-toggler:hover {
    background-color: var(--gray-100);
}

.navbar-toggler-icon {
    display: inline-block;
    width: 1.5em;
    height: 1.5em;
    vertical-align: middle;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(33, 37, 41, 0.75)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 100%;
}

.navbar-collapse {
    flex-basis: 100%;
    flex-grow: 1;
    align-items: center;
}

/* Hide mobile menu by default */
.navbar-collapse.collapse:not(.show) {
    display: none;
}

@media (min-width: 768px) {
    .navbar-collapse {
        display: flex !important;
        flex-basis: auto;
    }
    
    .navbar-toggler {
        display: none;
    }
}

/* ========================================
   Tables - Responsive
   ======================================== */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    margin-bottom: 1rem;
    color: var(--dark-text);
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 0.75rem;
    vertical-align: middle;
    border-top: 1px solid var(--gray-300);
}

.table thead th {
    vertical-align: bottom;
    border-bottom: 2px solid var(--gray-300);
    font-weight: 600;
    background-color: var(--gray-100);
}

.table tbody tr:hover {
    background-color: var(--gray-100);
}

/* ========================================
   Alerts & Messages
   ======================================== */
.alert {
    position: relative;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
}

.alert-success {
    color: #0f5132;
    background-color: #d1e7dd;
    border-color: #badbcc;
}

.alert-danger {
    color: #842029;
    background-color: #f8d7da;
    border-color: #f5c2c7;
}

.alert-info {
    color: #055160;
    background-color: #cff4fc;
    border-color: #b6effb;
}

.alert-dismissible {
    padding-right: 3rem;
}

.alert-dismissible .btn-close {
    position: absolute;
    top: 0;
    right: 0;
    padding: 1.25rem 1rem;
}

/* ========================================
   Login Page Styles
   ======================================== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 400px;
}

.login-card .card-body {
    padding: 2rem;
}

@media (max-width: 576px) {
    .login-card .card-body {
        padding: 1.5rem;
    }
}

/* ========================================
   Action Buttons Group
   ======================================== */
.action-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.action-buttons .btn {
    flex: 0 0 auto;
}

/* ========================================
   Filter Panel
   ======================================== */
.filter-panel {
    background-color: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--box-shadow-sm);
}

@media (max-width: 576px) {
    .filter-panel {
        padding: 1rem;
    }
}

/* ========================================
   Spacing Utilities
   ======================================== */
.p-0 { padding: 0 !important; }
.p-1 { padding: 0.25rem !important; }
.p-2 { padding: 0.5rem !important; }
.p-3 { padding: 1rem !important; }
.p-4 { padding: 1.5rem !important; }
.p-5 { padding: 3rem !important; }

.px-0 { padding-left: 0 !important; padding-right: 0 !important; }
.px-1 { padding-left: 0.25rem !important; padding-right: 0.25rem !important; }
.px-2 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
.px-3 { padding-left: 1rem !important; padding-right: 1rem !important; }
.px-4 { padding-left: 1.5rem !important; padding-right: 1.5rem !important; }

.py-0 { padding-top: 0 !important; padding-bottom: 0 !important; }
.py-1 { padding-top: 0.25rem !important; padding-bottom: 0.25rem !important; }
.py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }

/* ========================================
   Display Utilities
   ======================================== */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-inline-block { display: inline-block !important; }

@media (max-width: 576px) {
    .d-sm-none { display: none !important; }
    .d-sm-block { display: block !important; }
}

@media (min-width: 768px) {
    .d-md-none { display: none !important; }
    .d-md-block { display: block !important; }
    .d-md-flex { display: flex !important; }
}

/* ========================================
   Text Utilities
   ======================================== */
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

.text-primary { color: var(--primary-color) !important; }
.text-success { color: var(--success-color) !important; }
.text-danger { color: var(--danger-color) !important; }
.text-muted { color: var(--gray-600) !important; }

.fw-bold { font-weight: 700 !important; }
.fw-normal { font-weight: 400 !important; }

/* ========================================
   Accessibility
   ======================================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ========================================
   Footer Styles
   ======================================== */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container-fluid {
    flex: 1;
}

.footer {
    margin-top: auto;
    background-color: var(--light-bg);
    border-top: 1px solid var(--gray-300);
    padding: 1.5rem 0;
}

.footer p {
    margin-bottom: 0.25rem;
}

.footer .text-muted {
    color: var(--gray-600) !important;
}

@media (max-width: 576px) {
    .footer {
        padding: 1rem 0;
        text-align: center;
    }
    
    .footer .col-md-6 {
        margin-bottom: 0.5rem;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .navbar,
    .btn,
    .filter-panel,
    .action-buttons,
    .footer {
        display: none !important;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid var(--gray-300);
    }
}
