/* style.css - Subscription Tracker */

:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a2332;
    --bg-tertiary: #243044;
    --text-primary: #e7edf4;
    --text-secondary: #8b9eb3;
    --text-muted: #5c7089;
    --accent: #3d9eff;
    --accent-hover: #5eb0ff;
    --danger: #f85149;
    --danger-hover: #ff6b63;
    --warning: #d29922;
    --success: #3fb950;
    --border: #2d3f54;
    --border-light: #3d5068;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    --radius: 6px;
    --radius-lg: 10px;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
}

body {
    font-family: "JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.home-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

.home-link:hover {
    color: var(--accent);
    background: var(--bg-tertiary);
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

header h1 a {
    color: var(--text-primary);
    text-decoration: none;
}

header h1 a:hover {
    color: var(--accent);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.admin-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(63, 185, 80, 0.15);
    color: var(--success);
    border-radius: 4px;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg-primary);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: var(--bg-primary);
}

.btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

.btn-full {
    width: 100%;
    text-align: center;
}

/* Actions Bar */
.actions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    font-size: 0.875rem;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

th:first-child {
    border-top-left-radius: var(--radius-lg);
}

th:last-child {
    border-top-right-radius: var(--radius-lg);
}

tbody tr {
    transition: background 0.1s ease;
}

tbody tr:hover {
    background: var(--bg-tertiary);
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr.auto-renew {
    background: rgba(210, 153, 34, 0.08);
}

tbody tr.auto-renew:hover {
    background: rgba(210, 153, 34, 0.15);
}

tbody tr.expiring-soon {
    background: rgba(248, 81, 73, 0.12);
}

tbody tr.expiring-soon:hover {
    background: rgba(248, 81, 73, 0.2);
}

tbody tr.expiring-soon.auto-renew {
    background: linear-gradient(90deg, rgba(248, 81, 73, 0.12) 0%, rgba(210, 153, 34, 0.12) 100%);
}

tbody tr.expiring-soon.auto-renew:hover {
    background: linear-gradient(90deg, rgba(248, 81, 73, 0.2) 0%, rgba(210, 153, 34, 0.2) 100%);
}

.service-name {
    font-weight: 600;
    color: var(--text-primary);
}

.date-cell {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.price-cell {
    white-space: nowrap;
}

.price {
    font-weight: 600;
    color: var(--success);
}

.currency {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: 0.25rem;
}

.note-cell {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}

.text-right {
    text-align: right;
}

.renew-cell {
    text-align: center;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-radius: 4px;
}

.badge-warn {
    background: rgba(210, 153, 34, 0.2);
    color: var(--warning);
}

.badge-muted {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

.badge-danger {
    background: rgba(248, 81, 73, 0.2);
    color: var(--danger);
    font-weight: 600;
}

/* Actions Cell */
.actions-col {
    width: 140px;
}

.actions-cell {
    white-space: nowrap;
}

.actions-cell .btn {
    margin-right: 0.25rem;
}

.actions-cell .btn:last-child {
    margin-right: 0;
}

.inline-form {
    display: inline;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px dashed var(--border);
}

.empty-state p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Forms */
.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.form-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.subscription-form {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group-full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    font-family: inherit;
    font-size: 0.9375rem;
    padding: 0.65rem 0.85rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(61, 158, 255, 0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group select {
    cursor: pointer;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea {
    border-color: var(--danger);
}

.form-group .error {
    color: var(--danger);
    font-size: 0.75rem;
    margin-top: 0.35rem;
}

.form-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
}

/* Responsive */
@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    .container {
        padding: 1rem;
    }

    header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    header h1 {
        text-align: center;
    }

    .header-nav {
        justify-content: center;
    }

    .actions-bar {
        flex-direction: column;
    }

    .actions-bar .btn {
        width: 100%;
        text-align: center;
        padding: 0.75rem 1rem;
    }

    table {
        min-width: 700px;
    }

    th, td {
        padding: 0.6rem 0.75rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
        text-align: center;
        padding: 0.75rem 1rem;
    }

    .actions-col {
        width: auto;
    }

    .actions-cell {
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
    }

    .actions-cell .btn {
        margin-right: 0;
        padding: 0.5rem 0.75rem;
    }

    .subscription-form {
        padding: 1.25rem;
    }

    .empty-state {
        padding: 2.5rem 1.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
    }

    header h1 {
        font-size: 1.25rem;
    }

    .form-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .form-header .btn {
        width: 100%;
        text-align: center;
    }

    .login-box {
        padding: 1.5rem;
    }

    .table-wrapper {
        border-radius: var(--radius);
        margin: 0 -0.75rem;
        width: calc(100% + 1.5rem);
        border-left: none;
        border-right: none;
        border-radius: 0;
    }

    th:first-child,
    th:last-child {
        border-radius: 0;
    }
}

/* Scroll hint for tables on mobile */
@media (max-width: 768px) {
    .table-wrapper {
        position: relative;
    }

    .table-wrapper::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to right, transparent, var(--bg-secondary));
        pointer-events: none;
        opacity: 1;
        transition: opacity 0.2s;
    }

    .table-wrapper:hover::after {
        opacity: 0;
    }
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50vh;
}

.login-box {
    width: 100%;
    max-width: 360px;
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.login-box h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.login-desc {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.login-form .form-group {
    margin-bottom: 0;
}

.login-form .form-group input {
    width: 100%;
}

.error-message {
    background: rgba(248, 81, 73, 0.15);
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.back-link {
    display: block;
    text-align: center;
    margin-top: 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
}

.back-link:hover {
    color: var(--accent);
}

/* Additional mobile improvements */
@media (max-width: 768px) {
    .header-nav {
        width: 100%;
        justify-content: center;
    }

    .form-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .form-header .btn {
        width: 100%;
        text-align: center;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .btn-small {
        min-height: 36px;
        padding: 0.5rem 0.75rem;
    }

    tbody tr:hover {
        background: transparent;
    }

    tbody tr:active {
        background: var(--bg-tertiary);
    }

    .table-wrapper::after {
        display: none;
    }
}
