/* ============================================================
   SRD BILLING SOFTWARE - MASTER UI DESIGN SYSTEM
   Color Palette: Primary #17324D | Accent #1A73E8 | Bg #F5F7FA
   ============================================================ */

:root {
    --sidebar-bg: #112338;
    --sidebar-text: #94A3B8;
    --sidebar-active: #1A73E8;
    --sidebar-active-text: #FFFFFF;
    
    --bg-main: #F5F7FA;
    --card-bg: #FFFFFF;
    --border-color: #E2E8F0;
    
    --text-primary: #17202A;
    --text-muted: #64748B;
    
    --btn-primary: #1A73E8;
    --btn-primary-hover: #1557B0;
    --btn-success: #10B981;
    --btn-danger: #EF4444;
    
    --font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* APP LAYOUT */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: 240px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.brand-box {
    transition: opacity 0.2s ease, visibility 0.2s ease, width 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
}

.brand-title {
    font-size: 20px;
    font-weight: 800;
    color: #FFFFFF;
    letter-spacing: -0.5px;
}

.brand-subtitle {
    font-size: 12px;
    color: #64748B;
    margin-top: 2px;
}

.sidebar-collapse-btn,
.sidebar-toggle-btn {
    background: transparent;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
}

.sidebar-collapse-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
}

.sidebar-collapse-btn .collapse-icon {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-toggle-btn {
    color: var(--text-muted);
}

.sidebar-toggle-btn:hover {
    background-color: #F1F5F9;
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
    transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    color: #94A3B8;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
}

.nav-text {
    transition: opacity 0.2s ease, visibility 0.2s ease;
    white-space: nowrap;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: #FFFFFF;
}

.nav-item.active {
    background-color: var(--sidebar-active);
    color: #FFFFFF;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3);
}

.nav-item svg {
    width: 18px;
    height: 18px;
    margin-right: 12px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    flex-shrink: 0;
    transition: margin 0.2s ease;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    transition: padding 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.fy-select-box label {
    font-size: 11px;
    color: #64748B;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 6px;
}

.fy-select {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #FFFFFF;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
}

/* COLLAPSED SIDEBAR STATE */
body.sidebar-collapsed .sidebar {
    width: 68px;
}

body.sidebar-collapsed .main-wrapper {
    margin-left: 68px;
}

body.sidebar-collapsed .brand-box {
    opacity: 0;
    visibility: hidden;
    width: 0;
}

body.sidebar-collapsed .sidebar-header {
    padding: 16px 12px;
    justify-content: center;
}

body.sidebar-collapsed .sidebar-collapse-btn .collapse-icon {
    transform: rotate(180deg);
}

body.sidebar-collapsed .sidebar-nav {
    padding: 16px 8px;
}

body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}

body.sidebar-collapsed .nav-item svg {
    margin-right: 0;
}

body.sidebar-collapsed .nav-text {
    display: none;
}

body.sidebar-collapsed .sidebar-footer {
    padding: 12px 6px;
    text-align: center;
}

body.sidebar-collapsed .fy-select-box label {
    display: none;
}

body.sidebar-collapsed .fy-select {
    padding: 4px 2px;
    font-size: 11px;
    text-align: center;
}

/* TOOLTIP ON COLLAPSED NAV ITEMS */
body.sidebar-collapsed .nav-item[data-title]::after {
    content: attr(data-title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 12px;
    background-color: #0F172A;
    color: #FFFFFF;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

body.sidebar-collapsed .nav-item[data-title]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* MAIN CONTENT */
.main-wrapper {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.top-bar {
    background-color: #FFFFFF;
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}

.page-title-box h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.btn-logout {
    color: #EF4444;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
}

.content-area {
    padding: 24px;
    flex: 1;
}

/* CARDS & PANELS */
.card {
    background: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* FORM ELEMENTS */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
}

.form-group label .required {
    color: #EF4444;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #CBD5E1;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background-color: #FFFFFF;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.form-control:focus {
    outline: none;
    border-color: var(--btn-primary);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

/* SPECIFIC OPTIMIZED STYLING FOR INVOICE ITEMS TABLE INPUTS */
#invoice-items-table {
    min-width: 920px;
}

#invoice-items-table th,
#invoice-items-table td {
    padding: 12px 10px;
    vertical-align: middle;
}

#invoice-items-table .form-control {
    padding: 9px 12px;
    font-size: 14px;
    font-weight: 500;
    height: 42px;
    border-radius: 8px;
    border: 1.5px solid #CBD5E1;
}

#invoice-items-table .product-select {
    height: 38px !important;
    font-size: 13px !important;
    padding: 6px 10px !important;
    margin-bottom: 6px !important;
    background-color: #F8FAFC !important;
    border: 1.5px solid #CBD5E1 !important;
    border-radius: 6px !important;
    color: #334155 !important;
}

#invoice-items-table .item-desc {
    min-width: 250px;
}

#invoice-items-table .item-hsn {
    min-width: 95px;
}

#invoice-items-table .item-gst {
    min-width: 85px;
    text-align: center;
}

#invoice-items-table .item-qty {
    min-width: 90px;
    text-align: center;
}

#invoice-items-table .item-unit {
    min-width: 90px;
    text-align: center;
}

#invoice-items-table .item-rate {
    min-width: 115px;
    text-align: right;
}

#invoice-items-table .item-amount-text {
    font-size: 15px;
    font-weight: 700;
    color: #0F172A;
    display: inline-block;
    padding: 4px 6px;
    white-space: nowrap;
}

#invoice-items-table .btn-clone-row,
#invoice-items-table .btn-remove-row {
    padding: 8px 10px;
    font-size: 14px;
    border-radius: 6px;
    line-height: 1;
}

textarea.form-control {
    resize: vertical;
    min-height: 70px;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    gap: 8px;
}

.btn-primary {
    background-color: var(--btn-primary);
    color: #FFFFFF;
}

.btn-primary:hover {
    background-color: var(--btn-primary-hover);
}

.btn-secondary {
    background-color: #F1F5F9;
    color: #334155;
    border: 1px solid #CBD5E1;
}

.btn-secondary:hover {
    background-color: #E2E8F0;
}

.btn-danger {
    background-color: var(--btn-danger);
    color: #FFFFFF;
}

.btn-danger:hover {
    background-color: #DC2626;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* TABLES */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.table th, .table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background-color: #F8FAFC;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
}

.table tr:hover {
    background-color: #F8FAFC;
}

/* SPLIT VIEW LAYOUT FOR INVOICE FORM & LIVE PREVIEW */
.invoice-split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 1200px) {
    .invoice-split-layout {
        grid-template-columns: 1fr;
    }
}

.preview-container {
    position: sticky;
    top: 24px;
    background: #525659;
    padding: 20px;
    border-radius: 10px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.preview-toolbar {
    background: #323639;
    color: #FFF;
    padding: 8px 16px;
    border-radius: 6px 6px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 13px;
}

.preview-paper {
    background: #FFFFFF;
    width: 100%;
    min-height: 800px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    margin: 0 auto;
    padding: 24px;
}

/* ALERT MESSAGES */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success {
    background-color: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.alert-danger {
    background-color: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}
