/* ============================================================
   style.css — ХАРДУЕР ООД — Phoenix-inspired v3
   Тъмен сайдбар #1e2a3b, акценти #007FB0 и #8DC63F
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700&display=swap');

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

:root {
    --sidebar-bg:      #1e2a3b;
    --sidebar-hover:   #243447;
    --sidebar-active:  #2d3f56;
    --sidebar-text:    #9aacbf;
    --sidebar-text-active: #ffffff;
    --sidebar-width:   260px;

    --primary:         #007FB0;
    --primary-dark:    #005f87;
    --primary-light:   #e6f4fa;
    --success:         #8DC63F;
    --success-dark:    #6fa32e;
    --danger:          #e63757;
    --warning:         #f5a623;

    --body-bg:         #f5f7fa;
    --content-bg:      #ffffff;
    --border:          #e3e6ea;
    --text:            #21334a;
    --text-muted:      #748194;
    --card-shadow:     0 2px 12px rgba(0,0,0,.07);

    --radius:          8px;
    --radius-lg:       12px;
}

body {
    font-family: 'Nunito', sans-serif;
    background: var(--body-bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    overflow-y: auto;
    overflow-x: hidden;
}

/* Logo */
.logo-box {
    padding: 20px 20px 10px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    margin-bottom: 8px;
    flex-shrink: 0;
}
.logo-box a { display: block; }
.logo-mini {
    max-width: 140px;
    height: auto;
    display: block;
    background: white;
    border-radius: 8px;
    padding: 8px 12px;
}

/* Nav links */
.sidebar nav { flex: 1; padding: 8px 12px; }

.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar ul li { margin: 2px 0; }
.sidebar ul li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .18s, color .18s;
    white-space: nowrap;
}
.sidebar ul li a i {
    width: 18px;
    text-align: center;
    font-size: 14px;
    flex-shrink: 0;
}
.sidebar ul li a:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}
.sidebar ul li a.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0,127,176,.35);
}

/* Section label */
.sidebar-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: rgba(154,172,191,.5);
    padding: 14px 14px 4px;
    font-weight: 700;
}

/* Footer */
.sidebar-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.sidebar-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    color: white; font-weight: 700; font-size: 13px;
    flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name {
    font-size: 13px; font-weight: 600;
    color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 11px; color: var(--sidebar-text);
}
.logout-link {
    display: flex; align-items: center; gap: 8px;
    color: var(--sidebar-text); text-decoration: none;
    font-size: 13px; padding: 8px 10px;
    border-radius: var(--radius);
    transition: background .18s, color .18s;
}
.logout-link:hover { background: rgba(230,55,87,.15); color: #e63757; }

/* ============================================================
   TOP NAVBAR
   ============================================================ */
.topbar {
    position: fixed;
    top: 0; left: var(--sidebar-width); right: 0;
    height: 60px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 16px; font-weight: 700; color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* Hamburger — мобилно */
.hamburger {
    display: none;
    background: none; border: none;
    color: var(--text); font-size: 20px;
    cursor: pointer; padding: 6px;
    border-radius: var(--radius);
    transition: background .15s;
}
.hamburger:hover { background: var(--body-bg); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content,
.form-container,
.dashboard-container,
.fin-container {
    margin-left: var(--sidebar-width);
    padding: 80px 28px 28px;
    min-height: 100vh;
    background: var(--body-bg);
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}
.page-header-left { display: flex; align-items: center; gap: 12px; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--content-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    padding: 20px;
}
.card-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.card-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }

/* Metric cards */
.metric-card {
    background: var(--content-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.metric-icon {
    width: 46px; height: 46px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px; flex-shrink: 0;
}
.metric-icon.blue  { background: #e6f4fa; color: var(--primary); }
.metric-icon.green { background: #edf7df; color: var(--success-dark); }
.metric-icon.red   { background: #fde8ec; color: var(--danger); }
.metric-icon.gray  { background: #f0f2f5; color: var(--text-muted); }
.metric-body {}
.metric-card .mc-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.metric-card .mc-value { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.2; margin-top: 2px; }
.mc-blue  .mc-value { color: var(--primary); }
.mc-green .mc-value { color: var(--success-dark); }
.mc-red   .mc-value { color: var(--danger); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
    background: var(--content-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
table { border-collapse: collapse; width: 100%; min-width: 560px; }
table th {
    background: #f8f9fb;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-align: left;
}
table td {
    padding: 13px 16px;
    border-bottom: 1px solid #f0f2f5;
    font-size: 13.5px;
    color: var(--text);
    vertical-align: middle;
}
table tbody tr:last-child td { border-bottom: none; }
table tbody tr:hover td { background: #f8fbff; }
table tr.row-active   td { background: #f0fbf0; }
table tr.row-expiring td { background: #fffbee; }
table tr.row-expired  td { background: #fff5f7; }
table tr.row-black    td { background: #f9f9f9; color: #aaa; }

.tbl-actions { display: flex; gap: 4px; justify-content: center; }
.tbl-actions a {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 14px;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.tbl-actions a:hover { background: var(--primary-light); color: var(--primary); }
.tbl-actions a.danger:hover { background: #fde8ec; color: var(--danger); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn, button,
.add-button, .save-button,
.btn-primary, .btn-success, .btn-light, .btn-danger {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 18px;
    border: none; border-radius: var(--radius);
    font-family: 'Nunito', sans-serif;
    font-size: 13.5px; font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all .18s;
    line-height: 1;
}
.btn-primary, .add-button {
    background: var(--primary); color: #fff;
    box-shadow: 0 3px 10px rgba(0,127,176,.25);
}
.btn-primary:hover, .add-button:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 14px rgba(0,127,176,.35);
    transform: translateY(-1px);
}
.btn-success, .save-button {
    background: var(--success); color: #fff;
    box-shadow: 0 3px 10px rgba(141,198,63,.3);
}
.btn-success:hover, .save-button:hover {
    background: var(--success-dark);
    box-shadow: 0 4px 14px rgba(141,198,63,.4);
    transform: translateY(-1px);
}
.btn-light {
    background: var(--content-bg); color: var(--text);
    border: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.btn-light:hover { background: var(--body-bg); transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #cc2f4b; transform: translateY(-1px); }
.btn-sm { padding: 6px 13px; font-size: 12.5px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-card {
    background: var(--content-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    padding: 28px;
    max-width: 660px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label {
    font-size: 12px; font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .05em;
}
.form-group label .req { color: var(--danger); }
.form-section-label {
    font-size: 11px; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em;
    grid-column: 1 / -1;
    padding-top: 12px; margin-top: 4px;
    border-top: 1px solid var(--border);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
input[type="number"],
input[type="file"],
textarea,
select {
    width: 100%;
    padding: 9px 13px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: 'Nunito', sans-serif;
    font-size: 13.5px;
    color: var(--text);
    background: var(--content-bg);
    transition: border-color .18s, box-shadow .18s;
    box-sizing: border-box;
    margin-bottom: 0;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,127,176,.12);
}
textarea { resize: vertical; min-height: 70px; }

/* Product rows */
.top-row { display: flex; gap: 14px; margin-bottom: 16px; }
.top-row input, .top-row select { flex: 1; margin-bottom: 0; }

.product-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.product-row input, .product-row select {
    padding: 8px 10px; height: 38px; margin-bottom: 0;
}
.product-row input[name="product_name[]"]     { flex: 3; }
.product-row input[name="quantity[]"]         { flex: 1; min-width: 55px; }
.product-row input[name="serial_number[]"]    { flex: 3; }
.product-row select[name="warranty_months[]"] { flex: 2; }
.product-row .btn-remove {
    flex: 0 0 36px; width: 36px; height: 38px;
    background: #fde8ec; color: var(--danger);
    border: 1.5px solid #fbd0d9;
    border-radius: var(--radius);
    cursor: pointer; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
.product-row .btn-remove:hover { background: var(--danger); color: white; border-color: var(--danger); }

.form-actions {
    display: flex; justify-content: space-between;
    margin-top: 24px; gap: 10px;
}

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px; font-weight: 700;
}
.badge-active   { background: #edf7df; color: #4a7c1f; }
.badge-expiring { background: #fff4de; color: #9a6a00; }
.badge-expired  { background: #fde8ec; color: #c0143c; }
.badge-admin    { background: #e6f4fa; color: var(--primary-dark); }
.badge-employee { background: #edf7df; color: #4a7c1f; }

/* ============================================================
   SEARCH BAR
   ============================================================ */
.search-bar {
    display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; align-items: center;
}
.search-bar input  { flex: 1; min-width: 180px; margin-bottom: 0; }
.search-bar select { width: auto; margin-bottom: 0; }
.search-bar .btn, .search-bar button { width: auto; flex-shrink: 0; }
.search-box { margin-bottom: 20px; }
.search-box input { max-width: 500px; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert-success {
    background: #edf7df; color: #3a6b10;
    padding: 12px 16px; border-radius: var(--radius);
    margin-bottom: 18px; font-size: 13.5px; font-weight: 500;
    border-left: 4px solid var(--success);
}
.alert-error {
    background: #fde8ec; color: #c0143c;
    padding: 12px 16px; border-radius: var(--radius);
    margin-bottom: 18px; font-size: 13.5px; font-weight: 500;
    border-left: 4px solid var(--danger);
}
.error {
    background: #fde8ec; color: #c0143c;
    padding: 10px 14px; border-radius: var(--radius);
    margin-bottom: 14px; font-size: 13.5px;
    border-left: 4px solid var(--danger);
}

/* ============================================================
   INFO BOX
   ============================================================ */
.info-box {
    background: var(--primary-light);
    border: 1px solid #c2e4f2;
    border-radius: var(--radius);
    padding: 14px 18px; margin-bottom: 20px;
}
.info-box p { margin: 3px 0; font-size: 13.5px; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex; align-items: center; justify-content: center;
}
.login-container {
    background: var(--content-bg);
    padding: 44px 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    width: 100%; max-width: 420px;
    text-align: center;
}
.logo { max-width: 200px; margin-bottom: 28px; }
.login-container h2 { color: var(--text); font-size: 22px; font-weight: 700; margin-bottom: 24px; }
.login-container input { margin-bottom: 12px; }
.login-container button { width: 100%; margin-top: 4px; padding: 11px; font-size: 15px; }

/* ============================================================
   FINANCE
   ============================================================ */
.amount-in    { color: #3a6b10; font-weight: 700; }
.amount-out   { color: var(--danger); font-weight: 700; }
.amount-black { color: #aaa; }
.no-pdf-badge {
    font-size: 10px; background: #555; color: #fff;
    padding: 1px 6px; border-radius: 10px; margin-left: 5px;
}
.warranty-tag {
    display: inline-block; font-size: 11px;
    background: var(--primary-light); color: var(--primary-dark);
    padding: 2px 8px; border-radius: 10px; text-decoration: none; margin-top: 3px;
}
.warranty-tag:hover { background: #c2e4f2; }
.type-toggle {
    display: flex; border: 1.5px solid var(--border);
    border-radius: var(--radius); overflow: hidden; margin-bottom: 20px;
}
.type-btn {
    flex: 1; padding: 10px; font-size: 14px; font-weight: 700;
    border: none; cursor: pointer; background: var(--body-bg); color: var(--text-muted);
    transition: all .2s; font-family: 'Nunito', sans-serif;
}
.type-btn.active-income  { background: #edf7df; color: #3a6b10; }
.type-btn.active-expense { background: #fde8ec; color: var(--danger); }

/* Months grid */
.months-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.month-card {
    background: var(--content-bg); border-radius: var(--radius-lg);
    border: 1px solid var(--border); padding: 20px;
    box-shadow: var(--card-shadow);
    transition: border-color .2s, box-shadow .2s, transform .2s;
    cursor: pointer;
}
.month-card:hover {
    border-color: var(--primary);
    box-shadow: 0 6px 20px rgba(0,127,176,.15);
    transform: translateY(-2px);
}
.month-card a { text-decoration: none; color: inherit; display: block; }
.mc-title { font-size: 15px; font-weight: 700; color: var(--primary); margin-bottom: 14px; }
.mc-row { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.mc-divider { border-top: 1px solid var(--border); margin: 10px 0; }
.add-month-card {
    background: var(--content-bg); border-radius: var(--radius-lg);
    border: 2px dashed var(--border); display: flex;
    align-items: center; justify-content: center; min-height: 150px;
    cursor: pointer; transition: all .2s;
}
.add-month-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.add-month-card a {
    text-decoration: none; color: var(--text-muted);
    font-size: 14px; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}
.add-month-card:hover a { color: var(--primary); }

/* ============================================================
   MISC
   ============================================================ */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.sub-info { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mt-6 { margin-top: 24px; }
h2 { color: var(--text); font-weight: 700; }
a.btn { color: var(--primary); font-weight: 600; text-decoration: none; }

/* Sidebar overlay */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 190;
}
.sidebar-overlay.visible { display: block; }
.sidebar-close {
    display: none; position: absolute; top: 14px; right: 14px;
    background: rgba(255,255,255,.1); border: none; color: white;
    width: 30px; height: 30px; border-radius: 6px;
    font-size: 16px; cursor: pointer;
    align-items: center; justify-content: center;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,.3);
    }
    .sidebar-close { display: flex; }
    .hamburger { display: flex; }
    .topbar { left: 0; }

    .main-content,
    .form-container,
    .dashboard-container,
    .fin-container {
        margin-left: 0;
        padding: 76px 16px 20px;
    }

    .months-grid { grid-template-columns: 1fr 1fr; }
    .card-grid-4 { grid-template-columns: 1fr 1fr; }
    .card-grid-3 { grid-template-columns: 1fr; }
    .form-grid   { grid-template-columns: 1fr; }
    .form-group.full { grid-column: 1; }
    .form-card { max-width: 100%; padding: 20px; }

    .top-row { flex-direction: column; gap: 8px; }
    .product-row { flex-wrap: wrap; }
    .product-row input[name="product_name[]"],
    .product-row input[name="serial_number[]"] { flex: 1 1 100%; }

    .form-actions { flex-direction: column; }
    .form-actions .btn,
    .form-actions button { width: 100%; justify-content: center; }

    .search-bar { flex-direction: column; }
    .search-bar input,
    .search-bar select,
    .search-bar button { width: 100%; }

    table th, table td { padding: 10px 12px; font-size: 12.5px; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 500px) {
    .months-grid  { grid-template-columns: 1fr; }
    .card-grid-4  { grid-template-columns: 1fr 1fr; }
    .metric-card  { padding: 14px; }
    .metric-card .mc-value { font-size: 18px; }
}